Skip to main content

Player

Inherits from DynamicInstance

Player is the class that represents a connected client to the experience.

Not Creatable

Summary

Properties

Methods

Events

Details

A Player object is 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 UserID since it is possible that the player can change their username.

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

  • You can get a table of the current Player objects using Players:GetPlayers, use this instead of Instance:GetChildren()

  • To detect the addition of Player objects, it is recommended to use the Players.PlayerAdded event

  • You can also detect the removal of a Player object using the Players.PlayerRemoved event


Properties

Anchored

Player.Anchored: bool=false

Determines whether or not the player is anchored. The idle animation still plays and this property does not reset on respawn/reset.


CanMove

Player.CanMove: bool=true

Determines whether or not the player can move.


ChatColor

Player.ChatColor: Color=

Parameters:

ParameterTypeDefaultDescription
255any-
255any-
255any-

The player's username color in the chat.

game["Players"]["willemsteller"].ChatColor = Color3.New(0, 1, 0)

ShirtID

Player.ShirtID: int

Determines the ID of the shirt the player is wearing.


PantsID

Player.PantsID: int

Determines the ID of the pants the player is wearing.


FaceID

Player.FaceID: int

Determines the ID of the face the player is wearing.


HeadColor

Player.HeadColor: Color

Specifies the color of the players's head.


Health

Player.Health: float=100

The current health of the player.


IsAdmin

Player.IsAdmin: bool

Returns whether or not the player is a Polytoria admin.


IsCreator

Player.IsCreator: bool

Returns whether or not the player is the creator of the current place.


IsInputFocused

Player.IsInputFocused: bool

Determines whether or not the player is currently focused on an input.

The Player .IsInputFocused property has been moved to the Input static class, however the property still exists on the Player class for backwards-compatibility.

JumpPower

Player.JumpPower: float=36

Specifies how high the player's jump is.


LeftArmColor

Player.LeftArmColor: Color

Specifies the color of the players's left arm.


LeftLegColor

Player.LeftLegColor: Color

Specifies the color of the players's left leg.


MaxHealth

Player.MaxHealth: float=100

Specifies the maximum health the player can have.


MaxStamina

Player.MaxStamina: float=3

Specifies the maximum stamina the player can have.


RespawnTime

Player.RespawnTime: float=5

Determines how long it takes between the player's death and respawn.


RightArmColor

Player.RightArmColor: Color

Specifies the color of the players's right arm.


RightLegColor

Player.RightLegColor: Color

Specifies the color of the players's right leg.


SittingIn

Player.SittingIn: Seat

Returns the seat the player is currently sitting in, nil if the player is not sitting in any seat.


SprintSpeed

Player.SprintSpeed: float=25

Determines how fast the player is while sprinting.

Remarks

Sprinting can be disabled by setting the player's SprintSpeed to their WalkSpeed.


Stamina

Player.Stamina: float=0

The player's current amount of stamina.


StaminaEnabled

Player.StaminaEnabled: bool=true

Determines whether or not stamina is enabled for the player.


StaminaRegen

Player.StaminaRegen: float=1.2

The rate at which stamina regenerates after being depleted for the player.


TorsoColor

Player.TorsoColor: Color

Specifies the color of the players's torso.


UserID

Player.UserID: int

Returns the player's user ID.


WalkSpeed

Player.WalkSpeed: float=16

Determines how fast the player walks.


Methods

DropTools

Player:DropTools()

Drops the tool the player is currently holding.


Kick

Player:Kick(?Reason: string)

Parameters:

ParameterTypeDefaultDescription
?Reasonstring-

Kicks the player from the server with an optional reason parameter.

Example

game["Players"].PlayerAdded:Connect(function(player)
if player.Name == "Player" then
player:Kick("You've been kicked from the server.")
end
end)

LoadAppearance

Player:LoadAppearance(userID: int)

Parameters:

ParameterTypeDefaultDescription
userIDint-

Loads the specified user ID's avatar on the player.

Example

-- Loads the appearance of willemsteller
player:LoadAppearance(2)

ClearAppearance

Player:ClearAppearance()

Clears the player's appearance. This will set their appearance to a gray avatar.

Example

-- Clears the appearance of the player
player:ClearAppearance()

OwnsItem

Player:OwnsItem(assetID: int, callback: function)

Parameters:

ParameterTypeDefaultDescription
assetIDint-
callbackfunction-

Checks if the player owns an item

The function will cache the result for 5 minutes.
There is a limit of 30 requests that can be made per minute per server.

Example

player:OwnsItem(24122, function(error, owns)
if error then
print("An error occurred!")
else
if owns then
print("Player owns Polytoria Cap!")
else
print("Player does not own Polytoria Cap!")
end
end
end)

ResetAppearance:void

Player:ResetAppearance:void()

Resets the player's appearance to their original appearance.

Example

-- Resets the player's appearance back to their avatar
player:ResetAppearance()

Respawn

Player:Respawn()

Respawns the player.


Sit

Player:Sit(Seat: Seat)

Parameters:

ParameterTypeDefaultDescription
SeatSeat-

Sit the player in a specific seat.


Unsit

Player:Unsit(addForce: bool)

Parameters:

ParameterTypeDefaultDescription
addForceboolfalse

Unsit the player.

Properties


Events

Chatted

Player.Chatted(message: string, event: table)

Parameters:

ParameterTypeDefaultDescription
messagestring-
eventtable{Player|message|Canceled}

Fires when the player sends a chat message. You can prevent other players from seeing the chat message by setting the event's Canceled property like this: event.Canceled = true.

Example

game["Players"]["willemsteller"].Chatted:Connect(function (message, event)
print("Player wrote: " .. message)
end)

Died

Player.Died()

Fires when the player dies.

Example

game["Players"]["willemsteller"].Died:Connect(function ()
print("Player died")
end)

Respawned

Player.Respawned()

Fires when the player respawns.

Example

game["Players"]["willemsteller"].Respawned:Connect(function ()
print("Player has respawned")
end)

Methods