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

How to make a script that accesses a player in the player folder?

Asked by 10 years ago

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!!!

1 answer

Log in to vote
1
Answered by
duckwit 1404 Moderation Voter
10 years ago

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
Ad

Answer this question