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

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

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.

3 comments

0

Why is script.Parent in there?

0

The way I have it set up, the stringvalue is not inside the script but in player along with the script.

0

Edited question to clarify what I have

1 answer

✓ Accepted answer

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 .

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