2
votes

So, I'm looking to run a script on a players client that basically activates 2 -1 saturation color correction effects to invert the colors on their screen and their screen only, but I've only been scripting for a few months, and I'm not really ready to write complex code.

here is the code:

   game.Workspace.Five.Touched:Connect(function(hit)
        if hit.Parent == game.Players.LocalPlayer.Character then
            game.Lighting.inverted1.Enabled = true
            game.Lighting.inverted2.Enabled = true
        end
    end)
2
Where is the LocalScript located?Jakye
Following up on @Jakye 's comment, take a look at the docs for LocalScripts. Including the information about where the script is located is important because it's possible your script isn't executing because it's not in one of the correct locations.Kylaaa

2 Answers

1
votes

Place the local script in StarterPlayerScripts.

enter image description here

I rewrote your code in a slightly better way. Place this code in the local script

Lighting = game:GetService('Lighting')

game.Workspace.Five.Touched:Connect(function(hit)
   if hit.Parent:FindFirstChild('Humanoid') then
      print('Runned')
      Lighting.inverted1.Enabled = true
      Lighting.inverted2.Enabled = true
   end
 end)

It's recommended to usegame:GetService('Service name') to use services. I also changed if hit.Parent == game.Players.LocalPlayer.The character then for if hit.Parent:FindFirstChild('Humanoid') then because it's simpler and the code runs faster than the character loads, so it gives an error and stops running. Link with GetService() API reference: https://developer.roblox.com/en-us/api-reference/function/ServiceProvider/getService

0
votes

ok i have solved it, using remote events i got the player that touched the brick and used the server to handle the color correction enabling