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

Would this work?

Asked by 8 years ago

Can someone tell me if I add something like local asd = nil in a function, then end the function and try doing local asd = game.Workspace, would they interfere with each-other?

Example script:

function Random()
    local asd = nil
end
local asd = game.Workspace

Sorry if this isn't really a good question for ScriptingHelpers, just curious.

1 answer

Log in to vote
1
Answered by
4Bros 550 Moderation Voter
8 years ago

Your answer is no, they won't interfere with each other. Anything created with local before it will basically only be able to be called from that scope.


function Random() local asd = nil print(asd) -- Nil end local asd = game.Workspace print(asd) -- Workspace ---- local derp = "derp" function showDerp() local derp = "hi" print(derp) end showDerp() -- Hi print(derp) -- derp --However if you do something like this: local derp = "derp" function showDerp() derp = "hi" -- No local before it, the script believes we are editing the one outside the function's context print(derp) -- derp end print(derp) -- derp
0
Thanks. ISellCows 2 — 8y
Ad

Answer this question