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

Is this the right way to set a global variable to be based on a players name?

Asked by
Rhuxus 25
8 years ago

Basically I have a stringvalue of the players name So would I just go

_G.script.Parent.PlayerName.Value = 'StuffHere'

That's what I have so far but I won't be able to test until the entire script is finished so I need to know now if it'd work or if there's something else I need to do.

EDIT: To clarify what exactly I have so far

Structure Player - Script, PlayerName stringvalue

script

_G.script.Parent.PlayerName.Value={
bank={},
checks={bankchanged=false,inventorychanged=false,inventorylimitreached=false,skilling=false,stopanim=false},
inventory={},
resources={},
skills={cooking={level=1,xp=0},fishing={level=1,xp=0}}
} --All the things that will be saved.

0
Why is `script.Parent` in there? BlueTaslem 18071 — 8y
0
The way I have it set up, the stringvalue is not inside the script but in player along with the script. Rhuxus 25 — 8y
0
Edited question to clarify what I have Rhuxus 25 — 8y

1 answer

Log in to vote
1
Answered by 8 years ago

Nope, that would return nil.

The script is searching for a child of _G named 'script'.

To include lua syntax when using hierarchies:

_G[script.Parent.PlayerName.Value]

[] is basically an alternate .

Ad

Answer this question