So ive got like 0 lua experience...know nothing but slowly trying to make an rpg for fun and learning bits of lua on the way.
so today ive run into something with fog
ive got multiple levels in my game for example desert and swampy, and i want them each to have their own fog/view distance....i have the ontouched script so when somone touches a brick it changed the fog level...problem is its not local so im pretty sure it would change it for everyone all over the game.
the script is
1
function onTouched(hit)
2
game.Lighting.FogEnd = ("500")
3
end
4
script.Parent.Touched:connect(onTouched)
someone said to make it a local script...but when i looked up how to use a local script i couldn't think of a way to do it :/....i need this to run when the player touches a brick and for them to be the only one who sees it....so someone can be in my desert map and see 1000 fog and someone be in my swampy map and see 250 fog. if someone could walk me through it i would very much appreciate it :)
First step! Click on Workspace and check Filtering enabled. Second step! Insert a part in Workspace called Desert Third step! Insert a Number value in the part called "Desert" and change it to the value of the Fog Forth step! Insert a local script into the player Fifth step! Paste in the localscript whats written down bellow
local torso = game.Players.LocalPlayer.Character.Torso local Maps = {Desert, Swamp} torso.Touched:connect(function(hit) for i,v in pairs(Maps) do if hit.Name == v.Name then if hit:FindFirstChild("Fog") then game.Lighting.FogEnd = Fog.Value end end end end)