PcoWSkbVqDnWTu_dm2ix
We use cookies on this site to enhance your user experience
Collapse Sidebar

Player

Show deprecated

Player

Show deprecated

A Player object a client that is currently connected. These objects are added to the Players service when a new player connects, then removed when they eventually disconnect from the server.

The Instance/Name property reflects the player’s username. When saving information about a player, you should use their Player/UserId since it is possible that a player can change their username.

There are several similar methods in the Players for working with Player objects. Use these over their respective Instance methods:

  • You can get a table of current Player objects using Players/GetPlayers; again, use this instead of Instance/GetChildren.
  • To detect the addition of Player objects, it is recommended to use the Players/PlayerAdded event (instead of Instance/ChildAdded on the Players service).
  • Similarly, you can detect the removal of Player objects using Players/PlayerRemoving, which fires just before the Player is removed (instead of Instance/ChildRemoved which fires after). This is important if you are saving information about the player that might be removed or cleaned up on-removal.

Properties

int

AccountAge

[ReadOnly] [NotReplicated]

Describes the player’s account age in days.

bool

AutoJumpEnabled

Determines whether the character of a player using a mobile device will automatically jump upon hitting an obstacle.

float

CameraMaxZoomDistance

The maximum distance the player’s camera is allowed to zoom out.

float

CameraMinZoomDistance

The minimum distance the player’s camera is allowed to zoom in.

CameraMode

CameraMode

Changes the camera’s mode to either first or third person.

bool

CanLoadCharacterAppearance

Determines whether the character’s appearance will be loaded when the player spawns. If false, the player will spawn with a default appearance.

Model

Character

A model containing the humanoid, arms, legs, torso, and scripts of a player’s character. Initially this property is set to nil, and is set when the player’s character spawns.

int64

CharacterAppearanceId

Determines the user ID of the account whose character appearance is used for a player’s character.

DevCameraOcclusionMode

DevCameraOcclusionMode

Sets how the default camera handles objects between the camera and the player.

DevComputerCameraMovementMode

DevComputerCameraMode

Lets developer overwrite the default camera mode for each player if the player is on a computer.

DevComputerMovementMode

DevComputerMovementMode

Lets developer overwrite the default movement mode for each player if the player is on a computer.

bool

DevEnableMouseLock

Determines if a player can toggle mouse lock by default.

DevTouchCameraMovementMode

DevTouchCameraMode

Lets developer overwrite the default camera movement mode for each player if the player is on a mobile device.

DevTouchMovementMode

DevTouchMovementMode

Lets developer overwrite the player’s movement mode if the player is on a touch device.

int64

FollowUserId

[ReadOnly] [NotReplicated]

Describes the user ID of the player who was followed into a game by a player.

float

HealthDisplayDistance

Sets the distance at which this player will see other Humanoid’s health bars. If set to 0, the health bars will not be displayed.

string

LocaleId

[Hidden] [ReadOnly] [NotReplicated]

This property shows the locale id that the local player has set for their Roblox account.

float

MaximumSimulationRadius

[NotReplicated]

The maximum value a Player’s Player/SimulationRadius can grow to.

MembershipType

MembershipType

[ReadOnly] [NotReplicated]

Holds an Enum of the account’s membership type (NBC, BC, TBC and OBC).

float

NameDisplayDistance

Sets the distance at which this player will see other Humanoid’s names. If set to 0, names are hidden.

bool

Neutral

Determines whether the player is on a specific team or not.

Instance

ReplicationFocus

Sets the part to focus replication around.

SpawnLocation

RespawnLocation

If set, the player will respawn at the given SpawnLocation.

float

SimulationRadius

The simulation radius of a Player’s Player/Character.

Team

Team

[NotReplicated]

Determines the Team with which a Player is associated.

BrickColor

TeamColor

Determines the Team with which a Player is associated.

int64

UserId

A unique identifying integer assigned to all user accounts.

Inherited from Instance: Show Hide

int

DataCost

[ReadOnly] [NotReplicated]
The cost of saving the instance using data persistence.
Instance

Parent

Determines the hierarchical parent of the `Instance`.
bool

RobloxLocked

If true, the `Instance` and its descendants cannot be indexed or edited by a `Script` or `LocalScript` and will throw an error if it is attempted.
string

ClassName

[ReadOnly] [NotReplicated]
A read-only string representing the class this `Instance` belongs to.
string

Name

A non-unique identifier of the `Instance`.
bool

Archivable

Determines if an `Instance` can be cloned using `/Instance/Clone` or saved to file.

Functions

void

ClearCharacterAppearance ( )

Removes all accessories and other character appearance objects from a player’s Character.

float

DistanceFromCharacter ( Vector3 point )

Returns the distance between the character’s head and the given Vector3 point. Returns 0 if the player has no character.

Array

GetFriendsOnline ( int maxFriends )

[Yields]

Return a dictionary of online friends, specified by maxFriends.

Dictionary

GetJoinData ( )

Returns a dictionary containing information on how the Player joined the game

Instance

GetMouse ( )

Returns the mouse being used by the client.

int

GetRankInGroup ( int64 groupId )

[Yields]

Returns the player’s rank in the group as an integer between 0 and 255, where 0 is a non-member and 255 is the group’s owner.

string

GetRoleInGroup ( int64 groupId )

[Yields]

Returns the player’s role in the group as a string, or “Guest” if the player isn’t part of the group.

bool

HasAppearanceLoaded ( )

Returns whether or not the appearance of the player’s character has loaded

bool

IsFriendsWith ( int64 userId )

[Yields]

Checks whether a player is a friend of the user with the given ID.

bool

IsInGroup ( int64 groupId )

[Yields]

Checks whether a player is a member of a group with the given ID.

void

Kick ( string message )

Forcibly disconnect a player from the game, optionally providing a message.

void

LoadCharacter ( )

[Yields]

Creates a new character for the player, removing the old one. Also clears the player’s Backpack and PlayerGui.

void

LoadCharacterAppearance ( Instance assetInstance )

Places the given instance either in the player’s character, head, or StarterGear based on the instance’s class.

void

LoadCharacterBlocking ( )

[Yields]

Functions similar to Player/LoadCharacter, but the request is processed synchronously instead of asynchronously.

This means that no other task will be able to continue until after the character has been loaded, including the rendering of the game and any other tasks.

Notes

  • This function is used by Roblox's backend server when rendering avatar thumbnails.


void

Move ( Vector3 walkDirection , bool relativeToCamera )

Causes the player’s character to walk in the given direction until stopped, or interrupted by the player (by using their controls).

void

RemoveCharacter ( )

Removes the player’s character.

void

SetAccountAge ( int accountAge )

Sets the AccountAge of the player.

void

SetSuperSafeChat ( bool value )

Sets whether or not the player sees filtered chats, rather than normal chats.

Inherited from Instance: Show Hide

string

GetFullName ( )

Returns a string describing the `Instance`'s ancestry.
RBXScriptSignal

GetPropertyChangedSignal ( string property )

Get an event that fires when a given property of an object changes.
Instance

FindFirstChildWhichIsA ( string className , bool recursive )

Returns the first child of the `Instance` for whom `Instance/IsA` returns true for the given className.
Array

GetDescendants ( )

[CustomLuaState]
Returns an array containing all of the `Instance`'s descendants.
bool

IsAncestorOf ( Instance descendant )

Returns true if an `Instance` is an ancestor of the given descendant.
bool

IsDescendantOf ( Instance ancestor )

Returns true if an `Instance` is a descendant of the given ancestor.
Instance

FindFirstChildOfClass ( string className )

Returns the first child of the `Instance` whose `Instance/ClassName|ClassName` is equal to the given className.
Instance

FindFirstChild ( string name , bool recursive )

Returns the first child of the `Instance` found with the given name.
Instance

FindFirstAncestorWhichIsA ( string className )

Returns the first ancestor of the `Instance` for whom `Instance/IsA` returns true for the given className.
Instance

FindFirstAncestorOfClass ( string className )

Returns the first ancestor of the `Instance` whose `Instance/ClassName` is equal to the given className.
Instance

FindFirstAncestor ( string name )

Returns the first ancestor of the `Instance` whose `Instance/Name` is equal to the given name.
bool

IsA ( string className )

Returns true if an `Instance`'s class matches or inherits from a given class
Instance

WaitForChild ( string childName , double timeOut )

[CustomLuaState] [CanYield]
Returns the child of the `Instance` with the given name. If the child does not exist, it will yield the current thread until it does.
string

GetDebugId ( int scopeLength )

[NotBrowsable]
Returns a coded string of the `Instance`s DebugId used internally by Roblox.
Objects

GetChildren ( )

Returns an array containing all of the `Instance`'s children.
void

Destroy ( )

Sets the `Instance/Parent` property to nil, locks the `Instance/Parent` property, disconnects all connections and calls Destroy on all children.
Instance

Clone ( )

Create a deep copy of a Roblox instance and descendants where `Archivable = true`.
void

ClearAllChildren ( )

This function destroys all of an `Instance`'s children.

Events

RBXScriptSignal

CharacterAdded ( Instance character )

Fired when a player’s character spawns or respawns.

RBXScriptSignal

CharacterAppearanceLoaded ( Instance character )

Fires when the the full appearance of a Player's Player/Character has been inserted.

RBXScriptSignal

CharacterRemoving ( Instance character )

Fired when a player’s character is about to be removed.

RBXScriptSignal

Chatted ( string message , Instance recipient )

Fires when a player chats in-game using Roblox’s provided chat bar.

RBXScriptSignal

Idled ( double time )

Usually fired two minutes after the game engine classes the player as idle. Time is the amount of seconds since this point.

RBXScriptSignal

OnTeleport ( TeleportState teleportState , int64 placeId , string spawnName )

Fired when the TeleportState of a player changes.

RBXScriptSignal

SimulationRadiusChanged ( float radius )

Fired when the Player's Player/SimulationRadius is changed.

Inherited from Instance: Show Hide

RBXScriptSignal

DescendantRemoving ( Instance descendant )

Fires immediately before a descendant of the `Instance` is removed.
RBXScriptSignal

AncestryChanged ( Instance child , Instance parent )

Fires when the `Instance/Parent` property of the object or one of its ancestors is changed.
RBXScriptSignal

ChildAdded ( Instance child )

Fires when an object is parented to this `Instance`.
RBXScriptSignal

ChildRemoved ( Instance child )

Fires when a child is removed from this `Instance`.
RBXScriptSignal

DescendantAdded ( Instance descendant )

Fires when a descendant is added to the `Instance`.
RBXScriptSignal

Changed ( string property )

Fired immediately after a property of an object changes.