Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Ontouched Local fog change?

Asked by
nicros 165
9 years ago

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 :)

1 answer

Log in to vote
0
Answered by
crut24 50
9 years ago

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)
0
really appreciate the detailed walkthrough and scipt you provided.....me knowing nothing tho..i got stuck when adding it to my game...i know how to create the local script, but i dont know where "the player" is....i see "players" and "starterPlayer"....also where you say "Insert a Number value in the part called "Fog" and change it to the value of the Fog" im kind of lost where it says --->continu nicros 165 — 9y
0
if hit:FindFirstChild("Fog") then...do i change the ("Fog") to say for example ("250") or something else? and how would i have multiple values? so if they touch swampy brick it is 250 fog and if they touch desert brick it is 1000 fog....and dont feel you have to help me :p just say the word and ill understand nicros 165 — 9y
0
Well i ment to say that you need to insert a Number value in the part called Desert or Swamp. Then change the value of the Number Value to the value of the fog in Desert or Swamp crut24 50 — 9y
Ad

Answer this question