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

Does variables change for the whole server?

Asked by 3 years ago
Edited 3 years ago

Im new to scripting and I wonder if the following will change the variable number for the whole server or for just that one player that touched it.

local Var = true

local function ChangeVar(part)

if part.Parent.FindFirstChildWhichIsA("Humanoid") then

    Var = false

end

end

script.Parent.Touched:Connect(ChangeVar)

How do you know if a variable changed for the whole server or just for a single player. Is there something in a code that will tell you that? Thank You

2 answers

Log in to vote
0
Answered by 3 years ago

if u use a local like local thing1 = thing then that would only run for that script but if u used _G.var_name = something then that would be for the whole server

0
insert your var name into var_name btw botw_legend 502 — 3y
0
please click answer if this helped! botw_legend 502 — 3y
Ad
Log in to vote
0
Answered by
Fifkee 2017 Community Moderator Moderation Voter
3 years ago

It will not. Scripts only have two keywords that persists through scripts of the same type, the _G keyword, and the shared keyword. It's not good practice to use this as you never know when those keywords will initialize a variable without polling.

Answer this question