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

Way's to define a Player?

I only 2 ways, local Player = game.Players.LocalPlayer and local Player = Brick.Parent:findfirstChild("Humanoid") Can you guys tell em any more ways? Thanks.

1 comment

0

A Humanoid is not a Player.

2 answers

✓ Accepted answer

There are several ways to get the Player from the client or server

Client side

First and most common method is:

game:GetService'Players'.LocalPlayer

The other way is to do:

game.Players.LocalPlayer

But this method is deprecated, so you shouldn't do it this way

Server side

The easy way to access a player is:

game:GetService'Players':FindFirstChild(PlayerName)

But make sure to have an if statement checking if the player exists

Another way is to do:

game:GetService'Players'[PlayerName]

A way to access a player from character is to do:

game:GetService'Players':GetPlayerFromCharacter(workspace.PlayerName)

This also works on client side, but more commonly used server side

game.Players.LocalPlayer is for accessing the player of the client the script is running on.

GetPlayerFromCharacter will return a player given their character.

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