So this is the server script,
local AmbientChanger = workspace.AmbientChanger debounce = false AmbientChanger.Touched:Connect(function(hit) print("Touched!") if not debounce and hit.Parent:FindFirstChild("Humanoid") then debounce = true workspace.RemoteEvents.AmbientChangerEvent:FireClient() end debounce = false end)
while this is the local script, which is in the RemoteEvent
script.Parent.OnClientEvent:Connect(function() print("Recieved!") if game.Lighting.FogEnd == 100000 then for i = -1000, 100000, 500 do game.Lighting.FogEnd = i game.Lighting.FogColor = Color3.new(255, 255, 255) end else for i = 1000, 500, 100000 do game.Lighting.FogEnd = i end end end)
It doesn't even seem to detect that the brick is getting touched though, and I can't figure out why. FilteringEnabled is on.
On line 9, in your first script, you are firing the remote event to a client. however, u didnt pass any valid arguments, so no client receives it. As the touch function would fetch the character, which is on the server, the remote event wouldn't be needed. Instead to do this:
--In StarterPlayerScripts local debounce = false workspace.AmbientChanger.Touched:Connect(function(hit) if debounce == false then debounce = true if hit.Parent == game.Players.LocalPlayer.Character then if game.Lighting.FogEnd == 100000 then --Make sure other events wouldn't change this prior! for i = -1000, 100000, 500 do game.Lighting.FogEnd = i game.Lighting.FogColor = Color3.fromRGB(255, 255, 255) --RGB, not New, is out of 255 end else for i = 1000, 500, 100000 do --Change the third argument? Would give off an error. game.Lighting.FogEnd = i end end end end debounce = false end)
Now, let me explain this, as you're trying to change the lighting on the client, and you need to know if that same client touches the part, it should all be done on a local script, eliminating the need of a local script. Rather, you should place the touched function in the same script. As well as checking if there is a humanoid, I would also check if on of the parts on the client's characters set it off. If so, it'll continue on with the rest of your code.
All in all, if you need to change stuff on the client with :Touched events, just combine them in a localscript, while adding some precautions so it'll work.
Hope this helps!