Player
Inherits from DynamicInstance
Player is the class that represents a connected client to the experience.
Not CreatableSummary
Properties
Anchored:bool=falseCanMove:bool=trueChatColor:Color=ShirtID:intPantsID:intFaceID:intHeadColor:ColorHealth:float=100IsAdmin:boolRead OnlyIsCreator:boolRead OnlyIsInputFocused:boolRead OnlyJumpPower:float=36LeftArmColor:ColorLeftLegColor:ColorMaxHealth:float=100MaxStamina:float=3RespawnTime:float=5RightArmColor:ColorRightLegColor:ColorSittingIn:SeatSprintSpeed:float=25Stamina:float=0StaminaEnabled:bool=trueStaminaRegen:float=1.2TorsoColor:ColorUserID:intRead OnlyWalkSpeed:float=16
Methods
DropTools:voidKick:voidLoadAppearance:voidClearAppearance:voidOwnsItem:voidResetAppearance:void:voidRespawn:voidSit:voidUnsit:void
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
Playerobjects using Players:GetPlayers, use this instead of Instance:GetChildren() -
To detect the addition of
Playerobjects, it is recommended to use the Players.PlayerAdded event -
You can also detect the removal of a
Playerobject 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:
| Parameter | Type | Default | Description |
|---|---|---|---|
255 | any | - | |
255 | any | - | |
255 | any | - |
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.
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.
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:
| Parameter | Type | Default | Description |
|---|---|---|---|
?Reason | string | - |
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:
| Parameter | Type | Default | Description |
|---|---|---|---|
userID | int | - |
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:
| Parameter | Type | Default | Description |
|---|---|---|---|
assetID | int | - | |
callback | function | - |
Checks if the player owns an item
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:
| Parameter | Type | Default | Description |
|---|---|---|---|
Seat | Seat | - |
Sit the player in a specific seat.
Unsit
Player:Unsit(addForce: bool)
Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
addForce | bool | false |
Unsit the player.
Properties
Events
Chatted
Player.Chatted(message: string, event: table)
Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
message | string | - | |
event | table | {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)