Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Would this work?

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

✓ Accepted answer

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




1 comment

0

Thanks.

This discussion is preserved as it was. New answers, comments, and votes are closed.