How to change fog for 1 player

Im trying to make a part and when you touch it it changes your fog.

I have done,

function onTouch(hit)
game.Lighting.FogEnd = 100
end

script.Parent.Touched:Connect(onTouch)
1 Like

You could use a RemoteEvent for this.

1 Like

Just change the script to a LocalScript, change the script.Parent to where you want your touched Part to be, and put it inside StarterCharacter/StarterPlayer Scripts

1 Like

whenever I tried that it would change for both players,

And the script is in StarterPlayerScripts

Wait, what exactly are you trying to do then? Are you attempting to change the fog for just 1 player alone (Client wise)? Or is it for the entire server to see?

for just 1 player when they touch the brick

local thePart = workspace.somePart
function onTouch(hit)
   if hit.Parent:FindFirstChild("Humanoid") and hit.Parent == game.Players.LocalPlayer.Character then
      game.Lighting.FogEnd = 100
   end
end

somePart.Touched:Connect(onTouch)

Give this a try if you don’t mind. Make sure to change the thePart variable to your part.

2 Likes

thanks for the script! and its working now!

using touched and touch ended isnt best option, use region3.