PLEASE help me make a script that can access a player in the player folder... I need it to access a player with any name. (The game can only have one player in it) I NEED HELP!!!
✓ ANSWER ACCEPTED
How to make a script that accesses a player in the player folder?
1 answer
✓ Accepted answer
If the game only has one Player in it (i.e. a maximum server size of 1) then:
From a LocalScript you can just use
player = game.Players.LocalPlayer
From a global (normal) script you can use:
player = game.Players:GetChildren()[1]
In both cases it'd be best to wait for the player to exist before attempting to access it:
For the LocalScript version use:
while not game.Players.LocalPlayer do wait() end
For the global script version use:
while not #game.Players:GetChildren() > 0 do wait() end
This discussion is preserved as it was. New answers, comments, and votes are closed.
