rojo/.cursor/rules/roblox/reference/engine/classes/Player.yaml
2026-02-02 12:08:47 -06:00

2823 lines
93 KiB
YAML

# This file is automatically generated. Please don't edit it manually.
# To submit a bug report on the content, see
# https://devforum.roblox.com/c/bug-reports/documentation-issues/72
name: Player
type: class
memory_category: Instances
summary: |
An object that represents a presently connected client to the experience.
description: |
A `Player` object is a client that is currently connected. These objects are
added to the `Class.Players` service when a new player connects, then removed
when they eventually disconnect from the server.
The `Class.Instance.Name` property reflects the player's username. When saving
information about a player, you should use their `Class.Player.UserId|UserId`
since it is possible that a player can change their username.
There are several similar methods in the `Class.Players` service for working
with Player objects. Use these over their respective `Class.Instance` methods:
- You can get a table of current `Player` objects using
`Class.Players:GetPlayers()`; again, use this instead of
`Class.Instance:GetChildren()`.
- To detect the addition of `Player` objects, it is recommended to use the
`Class.Players.PlayerAdded` event (instead of `Class.Instance.ChildAdded` on
the `Class.Players` service).
- Similarly, you can detect the removal of `Player` objects using
`Class.Players.PlayerRemoving`, which fires just **before** the `Player` is
removed (instead of `Class.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.
code_samples: []
inherits:
- Instance
descendants: []
tags: []
deprecation_message: ''
properties:
- name: Player.AccountAge
summary: |
Describes the player's account age in days.
description: |
This property describes how long ago a player's account was registered in
days. It is set using the `Class.Player:SetAccountAge()|SetAccountAge()`
method, which cannot be accessed by scripts.
code_samples: []
type: int
tags:
- ReadOnly
- NotReplicated
deprecation_message: ''
security:
read: None
write: None
thread_safety: ReadSafe
category: Data
serialization:
can_load: false
can_save: false
capabilities:
- Players
- name: Player.AutoJumpEnabled
summary: |
Determines whether the character of a player using a mobile device will
automatically jump upon hitting an obstacle.
description: |
This property determines whether the `Class.Player.Character|Character` of
a `Class.Player` using a mobile device will automatically jump when they
hit an obstacle. This can make levels more navigable while on a mobile
device.
When the player joins the experience, the
`Class.StarterPlayer.AutoJumpEnabled` value determines the initial state
of this property. Then, this property determines the value of the
`Class.Humanoid.AutoJumpEnabled` property of the
`Class.Player.Character|Character` on spawn. In other words, it is
possible to set the auto-jump behavior on a per-character, per-player, and
per-experience basis using these three properties.
code_samples:
- Auto-Jump-Toggle
type: boolean
tags: []
deprecation_message: ''
security:
read: None
write: None
thread_safety: ReadSafe
category: Data
serialization:
can_load: true
can_save: true
capabilities:
- Players
- name: Player.CameraMaxZoomDistance
summary: |
The maximum distance the player's camera is allowed to zoom out.
description: |
This property sets the maximum distance the player's camera is allowed to
zoom out, in studs.
The default value of this property is set by
`Class.StarterPlayer.CameraMaxZoomDistance`. If this value is set to a
lower value than
`Class.Player.CameraMinZoomDistance|CameraMinZoomDistance`, it will be
increased to `Class.Player.CameraMinZoomDistance|CameraMinZoomDistance`.
code_samples: []
type: float
tags: []
deprecation_message: ''
security:
read: None
write: None
thread_safety: ReadSafe
category: Camera
serialization:
can_load: true
can_save: true
capabilities:
- Players
- name: Player.CameraMinZoomDistance
summary: |
The minimum distance the player's camera is allowed to zoom in.
description: |
This property sets the minimum distance the player's camera is allowed to
zoom in, in studs.
The default value of this property is set by
`Class.StarterPlayer.CameraMinZoomDistance`. If this value is set to a
higher value than
`Class.Player.CameraMaxZoomDistance|CameraMaxZoomDistance`, it will be
decreased to `Class.Player.CameraMaxZoomDistance|CameraMaxZoomDistance`.
code_samples: []
type: float
tags: []
deprecation_message: ''
security:
read: None
write: None
thread_safety: ReadSafe
category: Camera
serialization:
can_load: true
can_save: true
capabilities:
- Players
- name: Player.CameraMode
summary: |
Changes the camera's mode to either first or third person.
description: |
This property sets the player's camera mode, defaulting to third person.
#### Third Person
In the default third person mode (`Enum.CameraMode.Classic`), the
character can be seen in the camera. While in this mode, the default
behavior is:
- Players can right-click and drag (mouse), tap and drag (mobile), use the
secondary thumbstick (gamepad), or press the left/right arrows
(keyboard) to rotate the camera around their character.
- When a player moves their character, it faces in the corresponding
movement direction.
- Players can zoom in and out freely, even to first person on full zoom
in.
#### First Person
In first person mode (`Enum.CameraMode.LockFirstPerson`), the player's
camera is zoomed all the way in. Unless there is a visible GUI present
with the `Class.GuiButton.Modal` property set to `true`, moving the mouse,
tap-dragging on mobile, or using the secondary thumbstick on a gamepad
will rotate the camera around the character.
code_samples:
- playing-in-first-person
type: CameraMode
tags: []
deprecation_message: ''
security:
read: None
write: None
thread_safety: ReadSafe
category: Camera
serialization:
can_load: true
can_save: true
capabilities:
- Players
- name: Player.CanLoadCharacterAppearance
summary: |
Determines whether the character's appearance will be loaded when the
player spawns. If `false`, the player will spawn with a default
appearance.
description: |
This property determines whether the character's appearance will be loaded
when the player spawns. The default value of this property is set by
`Class.StarterPlayer.LoadPlayerAppearance`.
- If `true`, the character will load the appearance of the player
corresponding to the player's
`Class.Player.CharacterAppearanceId|CharacterAppearanceId`.
- If `false`, the player will spawn with a default appearance.
Attempting to set the property after the character has spawned will not
change the character; you must call
`Class.Player:LoadCharacterAsync()|LoadCharacterAsync()` to load the new
appearance.
code_samples: []
type: boolean
tags: []
deprecation_message: ''
security:
read: None
write: None
thread_safety: ReadSafe
category: Behavior
serialization:
can_load: false
can_save: false
capabilities:
- Players
- name: Player.Character
summary: |
A `Class.Model` controlled by the player that contains a `Class.Humanoid`,
body parts, scripts, and other objects.
description: |
This property contains a reference to a `Class.Model` containing a
`Class.Humanoid`, body parts, scripts, and other objects required for
simulating the player's avatar in-experience. The model is parented to the
`Class.Workspace` but it may be moved. It is automatically loaded when
`Class.Players.CharacterAutoLoads` is `true` and it can be manually loaded
otherwise using `Class.Player:LoadCharacterAsync()|LoadCharacterAsync()`.
Initially this property is `nil` and it is set when the player's character
first spawns. Use the `Class.Player.CharacterAdded|CharacterAdded` event
to detect when a player's character properly loads, and the
`Class.Player.CharacterRemoving|CharacterRemoving` event to detect when
the character is about to despawn. Avoid using
`Class.Object:GetPropertyChangedSignal()` on this property.
Note that `Class.LocalScript|LocalScripts` that are cloned from
`Class.StarterGui` or `Class.StarterPack` into a player's
`Class.PlayerGui` or `Class.Backpack` respectively are often run before
the old character model is replaced, so `Class.Player.Character` may refer
to the old model whose `Class.Instance.Parent|Parent` property is `nil`.
Therefore, in a `Class.LocalScript` under `Class.StarterGui` or
`Class.StarterPack`, it is advisable to make sure the parent of
`Character` is not `nil` before using it, for example:
```lua
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local character = player.Character
if not character or character.Parent == nil then
character = player.CharacterAdded:Wait()
end
```
code_samples: []
type: Model
tags: []
deprecation_message: ''
security:
read: None
write: None
thread_safety: ReadSafe
category: Data
serialization:
can_load: true
can_save: true
capabilities:
- Players
- name: Player.CharacterAppearance
summary: |
The URL of the asset containing the character's appearance, clothing, and
gear.
description: |
This property indicates the URL of the asset containing the character's
appearance, clothing, and gear. It is automatically set by Roblox to load
your avatar's appearance when you join an experience.
Attempting to set the property after the character has spawned will not
change the character, you must call
`Class.Player:LoadCharacterAsync()|LoadCharacterAsync()` to load the new
appearance.
code_samples: []
type: string
tags:
- NotBrowsable
- Deprecated
deprecation_message: |
This item is deprecated. Do not use it for new work.
security:
read: None
write: None
thread_safety: ReadSafe
category: Data
serialization:
can_load: true
can_save: true
capabilities:
- Players
- name: Player.CharacterAppearanceId
summary: |
Determines the user ID of the account whose character appearance is used
for a player's `Class.Player.Character|Character`.
description: |
This property determines the user ID of the account whose character
appearance is used for a player's `Class.Player.Character|Character`. By
default, this property is the `Class.Player.UserId|UserId`, which uses the
player's avatar as they have created it on Roblox.
Changing this property to the user ID of another account will cause the
player to spawn with that account's appearance.
You can also toggle whether or not a player's character appearance is
loaded in experience by changing the
`Class.StarterPlayer.LoadCharacterAppearance` property.
code_samples: []
type: int64
tags: []
deprecation_message: ''
security:
read: None
write: None
thread_safety: ReadSafe
category: Data
serialization:
can_load: true
can_save: true
capabilities:
- Players
- name: Player.DataComplexity
summary: |
The total amount of data currently being stored in the player's cache on
the current place.
description: |
This property was once used by an ancient data persistence method to
indicate the total amount of data currently being stored in the player's
cache on the current place.
#### Notes
- Booleans and numbers cost 1 data complexity unit.
- Strings cost their length divided by 100 in data complexity units.
- Instances cost their DataCost in data complexity units.
- Saving the default value (0 for numbers, false for booleans, "" for
strings and `nil` for Instances) removes the key from the DataComplexity
count.
- If, when using the SaveBoolean, SaveString, SaveNumber or SaveInstance
functions, the DataComplexity for the player goes over the limit
(currently 45000 units, defined by DataComplexityLimit), the function
throws an error, the value is not saved, and any previous value of the
key that was being saved to is deleted.
code_samples: []
type: int
tags:
- Hidden
- ReadOnly
- NotReplicated
- Deprecated
deprecation_message: |
This item is deprecated, as it may have been used for a now obsolete data
persistence method. Please save and load player data using
`Class.DataStoreService` for new work.
security:
read: None
write: None
thread_safety: ReadSafe
category: Data
serialization:
can_load: false
can_save: false
capabilities:
- Players
- name: Player.DataReady
summary: |
Indicates when the player's data is available to load.
description: |
This property was once used by an ancient data persistence method to
indicate when the player's data is available to load. Becomes true when
data is available.
code_samples: []
type: boolean
tags:
- Hidden
- ReadOnly
- NotReplicated
- Deprecated
deprecation_message: |
This item is deprecated, as it may have been used for a now obsolete data
persistence method. Please save and load player data using
`Class.DataStoreService` for new work.
security:
read: None
write: None
thread_safety: ReadSafe
category: Data
serialization:
can_load: false
can_save: false
capabilities:
- Players
- name: Player.DevCameraOcclusionMode
summary: |
Sets how the default camera handles objects between the camera and the
player.
description: |
Defines how the default camera scripts handle objects between the camera
and the camera subject. Set by
`Class.StarterPlayer.DevCameraOcclusionMode` and can't be changed for
individual players.
The default value is `Enum.DevCameraOcclusionMode|Zoom`. See
`Enum.DevCameraOcclusionMode` for a list of available modes.
code_samples: []
type: DevCameraOcclusionMode
tags: []
deprecation_message: ''
security:
read: None
write: None
thread_safety: ReadSafe
category: Camera
serialization:
can_load: true
can_save: true
capabilities:
- Players
- name: Player.DevComputerCameraMode
summary: |
Determines player's camera movement mode when using a device with a mouse
and keyboard.
description: |
This property determines the manner in which a player moves their camera
when using a device with a mouse and keyboard. This property cannot be set
using a `Class.LocalScript` (it must be set on the server using a
`Class.Script`).
The default value of this property is determined by
`Class.StarterPlayer.DevComputerCameraMovementMode`.
This property doesn't affect players using a
`Class.UserInputService.TouchEnabled|TouchEnabled` device. See
`Class.Player.DevTouchCameraMode|DevTouchCameraMode` instead.
code_samples: []
type: DevComputerCameraMovementMode
tags: []
deprecation_message: ''
security:
read: None
write: None
thread_safety: ReadSafe
category: Camera
serialization:
can_load: true
can_save: true
capabilities:
- Players
- name: Player.DevComputerMovementMode
summary: |
Determines player's character movement mode when using a device with a
mouse and keyboard.
description: |
This property determines the manner in which a player moves their
character when using a device with a mouse and keyboard. This property
cannot be set using a `Class.LocalScript` (it must be set on the server
using a `Class.Script`).
The default value of this property is determined by
`Class.StarterPlayer.DevComputerMovementMode`.
This property doesn't affect players using a
`Class.UserInputService.TouchEnabled|TouchEnabled` device. See
`Class.Player.DevTouchMovementMode|DevTouchMovementMode` instead.
code_samples: []
type: DevComputerMovementMode
tags: []
deprecation_message: ''
security:
read: None
write: None
thread_safety: ReadSafe
category: Control
serialization:
can_load: true
can_save: true
capabilities:
- Players
- name: Player.DevEnableMouseLock
summary: |
Determines if the player can toggle mouse lock.
description: |
This property determines if a player is able to toggle mouse lock by
pressing <kbd>Shift</kbd>. A player can disable the mouse lock switch in
the experience's settings during play. By default, this property is set to
the value of `Class.StarterPlayer.EnableMouseLockOption`. This can be set
server-side during runtime by using a `Class.Script`. It can not be set
client-side.
When mouse lock is enabled, the player's cursor is locked to the center of
the screen. Moving the mouse will orbit the camera around the player's
`Class.Player.Character|Character`, and the character will face the same
direction as the `Class.Camera`. It also offsets the camera view just over
the right shoulder of the player's character.
code_samples: []
type: boolean
tags: []
deprecation_message: ''
security:
read: None
write: None
thread_safety: ReadSafe
category: Camera
serialization:
can_load: true
can_save: true
capabilities:
- Players
- name: Player.DevTouchCameraMode
summary: |
Determines player's camera movement mode when using a touch-enabled
device.
description: |
This property determines the manner in which a player moves their camera
when using a `Class.UserInputService.TouchEnabled|TouchEnabled` device.
This property cannot be set using a `Class.LocalScript` (it must be set on
the server using a `Class.Script`).
The default value of this property is determined by
`Class.StarterPlayer.DevTouchCameraMovementMode`.
This property doesn't affect players who aren't using a
`Class.UserInputService.TouchEnabled|TouchEnabled` device. See
`Class.Player.DevComputerCameraMode|DevComputerCameraMode` instead.
code_samples: []
type: DevTouchCameraMovementMode
tags: []
deprecation_message: ''
security:
read: None
write: None
thread_safety: ReadSafe
category: Camera
serialization:
can_load: true
can_save: true
capabilities:
- Players
- name: Player.DevTouchMovementMode
summary: |
Determines player's character movement mode when using a touch-enabled
device.
description: |
This property determines the manner in which a player moves their
character when using a `Class.UserInputService.TouchEnabled|TouchEnabled`
device. This property cannot be set using a `Class.LocalScript` (it must
be set on the server using a `Class.Script`).
The default value of this property is determined by
`Class.StarterPlayer.DevTouchMovementMode`.
This property doesn't affect players who aren't using a
`Class.UserInputService.TouchEnabled|TouchEnabled` device. See
`Class.Player.DevComputerMovementMode|DevComputerMovementMode` instead.
code_samples: []
type: DevTouchMovementMode
tags: []
deprecation_message: ''
security:
read: None
write: None
thread_safety: ReadSafe
category: Control
serialization:
can_load: true
can_save: true
capabilities:
- Players
- name: Player.DisplayName
summary: |
The display name of the authenticated user associated with the
`Class.Player`.
description: |
This property contains the display name of the authenticated user
associated with the `Class.Player` object. Unlike
`Class.Player.UserId|UserId`, display names are non-unique names a player
displays to others.
#### Usage Notes
- Since display names are non-unique, it's possible for two players in a
single instance to have identical names. If you need a globally unique
identifier for a player, use `Class.Player.UserId|UserId` instead.
- Characters generated with
`Class.Player:LoadCharacterAsync()|LoadCharacterAsync()` or by the
Roblox engine will have their `Class.Humanoid.DisplayName` property
assigned to the `Class.Player.DisplayName` property.
- Display names may have unicode characters in the string. See
`Library.utf8|UTF-8` for more information on how to work with strings
with unicode characters.
code_samples: []
type: string
tags: []
deprecation_message: ''
security:
read: None
write: None
thread_safety: ReadSafe
category: Data
serialization:
can_load: false
can_save: false
capabilities:
- Players
- name: Player.FollowUserId
summary: |
Describes the user ID of the player who was followed into an experience by
a player.
description: |
This property contains the `Class.Player.UserId|UserId` of the user that a
player followed into the experience, or `0` if the player did not follow
anyone in. This property is useful for alerting players who have been
followed by another player into the experience.
You can get the name of the player followed using this user ID and the
`Class.Players:GetNameFromUserIdAsync()` method.
code_samples:
- Followed-Alert
type: int64
tags:
- ReadOnly
- NotReplicated
deprecation_message: ''
security:
read: None
write: None
thread_safety: ReadSafe
category: Data
serialization:
can_load: false
can_save: true
capabilities:
- Players
- name: Player.GameplayPaused
summary: |
Whether player client-side gameplay is currently paused.
description: |
This property indicates if the player is currently in a pause state in a
place with `Class.Workspace.StreamingEnabled|StreamingEnabled` activated.
It is set on the client but replicated to the server.
#### See Also
- `Class.Workspace.StreamingEnabled` which controls whether content
streaming is enabled
- `Class.Workspace.StreamingIntegrityMode` and
`Enum.StreamingIntegrityMode` for more details on when gameplay is
paused.
code_samples: []
type: boolean
tags:
- Hidden
deprecation_message: ''
security:
read: None
write: NotAccessibleSecurity
thread_safety: ReadSafe
category: Behavior
serialization:
can_load: false
can_save: false
capabilities:
- Players
- name: Player.HasVerifiedBadge
summary: |
Indicates if a player has a **Verified** badge.
description: |
This property indicates if the player has a **Verified** badge.
code_samples: []
type: boolean
tags: []
deprecation_message: ''
security:
read: None
write: None
thread_safety: ReadSafe
category: Data
serialization:
can_load: false
can_save: false
capabilities:
- Players
- name: Player.HealthDisplayDistance
summary: |
Sets the distance at which this player will see other players' health
bars.
description: |
This property sets the distance in studs at which this player will see
other `Class.Humanoid` health bars. If set to `0`, the health bars will
not be displayed. This property is set to
`Class.StarterPlayer.HealthDisplayDistance` by default.
If a humanoid's health bar is visible, you can set the display type using
`Class.Humanoid.DisplayDistanceType`.
code_samples: []
type: float
tags: []
deprecation_message: ''
security:
read: None
write: None
thread_safety: ReadSafe
category: Camera
serialization:
can_load: true
can_save: true
capabilities:
- Players
- name: Player.LocaleId
summary: |
This property shows the locale ID that the local player has set for their
Roblox account.
description: |
This property shows the locale ID that the local player has set for their
Roblox account. It holds a string with the two letter code, for example
`en-us`.
See also `Class.LocalizationService.RobloxLocaleId`, the locale ID used
for localizing internal content. This will be a different value when
Roblox does not yet internally support the local player's set locale.
code_samples: []
type: string
tags:
- Hidden
- ReadOnly
- NotReplicated
deprecation_message: ''
security:
read: None
write: None
thread_safety: ReadSafe
category: Data
serialization:
can_load: false
can_save: false
capabilities:
- Players
- name: Player.MembershipType
summary: |
Describes the account's membership type.
description: |
This property can only be read from to determine membership (it cannot be
set to another membership type). It holds a `Enum.MembershipType` enum of
the account's membership type.
code_samples:
- check-membership-status
type: MembershipType
tags:
- ReadOnly
- NotReplicated
deprecation_message: ''
security:
read: None
write: None
thread_safety: ReadSafe
category: Data
serialization:
can_load: false
can_save: false
capabilities:
- Players
- name: Player.NameDisplayDistance
summary: |
Sets the distance at which this player will see other players' names.
description: |
This property sets the distance in studs at which this player will see
other `Class.Humanoid` names. If the property is set to `0`, names are
hidden. This property is set to `Class.StarterPlayer.NameDisplayDistance`
by default.
If a humanoid's name is visible, you can set the display type using
`Class.Humanoid.DisplayDistanceType`.
code_samples: []
type: float
tags: []
deprecation_message: ''
security:
read: None
write: None
thread_safety: ReadSafe
category: Camera
serialization:
can_load: true
can_save: true
capabilities:
- Players
- name: Player.Neutral
summary: |
Determines whether the player is on a specific team.
description: |
This property determines whether the player is on a specific team.
- When `true`, the player is not on a specific team. This also means that
the `Class.Player.Team|Team` property will be `nil` and the
`Class.Player.TeamColor|TeamColor` will be white.
- When `false`, the player is on a specific team. The
`Class.Player.Team|Team` property will correspond to the `Class.Team`
that the player is on, as will the `Class.Player.TeamColor|TeamColor`.
code_samples: []
type: boolean
tags: []
deprecation_message: ''
security:
read: None
write: None
thread_safety: ReadSafe
category: Team
serialization:
can_load: true
can_save: true
capabilities:
- Players
- name: Player.PartyId
summary: |
A unique identifier of the party a `Class.Player` belongs to.
description: |
A read-only string identifying the party the player currently belongs to
within the experience. If the player is not in a party, this value is an
empty string.
This property is essential for integrating with the Roblox Party feature.
Use it in combination with `Class.SocialService:GetPlayersByPartyId()` and
`Class.SocialService:GetPartyAsync()` to access information about a
player's party and its members.
To test this service in your experience, use the
[Party Simulator](../../../studio/testing-modes.md#party-simulation) in
Roblox Studio or publish the experience and play it in the Roblox
application.
code_samples:
- Player-PartyId
type: string
tags:
- Hidden
- NotReplicated
deprecation_message: ''
security:
read: None
write: RobloxEngineSecurity
thread_safety: ReadSafe
category: Data
serialization:
can_load: false
can_save: false
capabilities:
- Players
- name: Player.ReplicationFocus
summary: |
Sets the part to focus replication around.
description: |
This property sets the part to focus replication around a player.
Different Roblox systems that communicate over the network (such as
physics, streaming, etc.) replicate at different rates depending on how
close objects are to the replication focus.
When this property is `nil`, it reverts to its default behavior which is
to treat the local player's character's
`Class.Model.PrimaryPart|PrimaryPart` as the replication focus.
This property should only be set on the server with a `Class.Script`, not
a `Class.LocalScript`. Note that this property does not change or update
network ownership of parts.
code_samples: []
type: Instance
tags: []
deprecation_message: ''
security:
read: None
write: None
thread_safety: ReadSafe
category: Data
serialization:
can_load: true
can_save: true
capabilities:
- Players
- name: Player.RespawnLocation
summary: |
If set, the player will respawn at the given `Class.SpawnLocation`.
description: |
If set, the player will respawn at the given `Class.SpawnLocation` which
must meet the following criteria:
- Descendant of `Class.Workspace`.
- The `Class.SpawnLocation.TeamColor` property is set to the player's
`Class.Player.TeamColor|TeamColor` or the `Class.SpawnLocation.Neutral`
property is set to `true`.
#### Alternatives
- A `Class.Player` will spawn from `Class.SpawnLocation|SpawnLocations`
belonging to their team. In some cases it may be simpler to change the
player's `Class.Player.Team|Team` instead.
- Implement your own custom spawn logic using `Class.PVInstance:PivotTo()`
to manually move the `Class.Player.Character|Character`.
code_samples:
- change-spawn-on-touch
type: SpawnLocation
tags: []
deprecation_message: ''
security:
read: None
write: None
thread_safety: ReadSafe
category: Data
serialization:
can_load: true
can_save: true
capabilities:
- Players
- name: Player.StepIdOffset
summary: ''
description: ''
code_samples: []
type: int
tags: []
deprecation_message: ''
security:
read: RobloxEngineSecurity
write: RobloxEngineSecurity
thread_safety: ReadSafe
category: Data
serialization:
can_load: true
can_save: true
capabilities:
- Players
- name: Player.Team
summary: |
Determines the `Class.Team` with which the player is associated.
description: |
This property is a reference to a `Class.Team` object within the
`Class.Teams` service. If the player isn't on a team or has an invalid
`Class.Player.TeamColor|TeamColor`, this property is `nil`. When this
property is set, the player has joined the `Class.Team` and the
`Class.Team.PlayerAdded` event fires on the associated team. Similarly,
`Class.Team.PlayerRemoved` fires when the property is unset from a certain
`Class.Team`.
code_samples: []
type: Team
tags:
- NotReplicated
deprecation_message: ''
security:
read: None
write: None
thread_safety: ReadSafe
category: Team
serialization:
can_load: true
can_save: true
capabilities:
- Players
- name: Player.TeamColor
summary: |
Determines the `Class.Team` with which the player is associated with
according to that team's `Class.Team.TeamColor`.
description: |
This property determines which `Class.Team` a player is associated with
according to that team's `Class.Team.TeamColor`. If no `Class.Team` object
has the associated `Datatype.BrickColor`, the player will not be
associated with a team.
It's often a better idea to set `Class.Player.Team` to the respective
`Class.Team` instead of using this property. Setting this property often
leads to repetition of the same `Datatype.BrickColor` value for a certain
team across many scripts.
code_samples: []
type: BrickColor
tags: []
deprecation_message: ''
security:
read: None
write: None
thread_safety: ReadSafe
category: Team
serialization:
can_load: true
can_save: true
capabilities:
- Players
- name: Player.ThirdPartyTextChatRestrictionStatus
summary: ''
description: ''
code_samples: []
type: ChatRestrictionStatus
tags:
- ReadOnly
- NotReplicated
deprecation_message: ''
security:
read: RobloxScriptSecurity
write: RobloxScriptSecurity
thread_safety: ReadSafe
category: Data
serialization:
can_load: false
can_save: true
capabilities:
- Players
- name: Player.UserId
summary: |
A unique identifying integer assigned to all user accounts.
description: |
This property contains a read-only integer that **uniquely and
consistently** identifies the user's account on Roblox. Unlike the
player's `Class.Player.DisplayName|DisplayName` which may change, this
value will never change for the same account.
This property is essential when saving/loading player data using
`Class.GlobalDataStore|GlobalDataStores`.
code_samples:
- Player-UserId1
- GlobalDataStore-GetAsync1
type: int64
tags: []
deprecation_message: ''
security:
read: None
write: None
thread_safety: ReadSafe
category: Data
serialization:
can_load: false
can_save: false
capabilities:
- Players
- name: Player.userId
summary: ''
description: ''
code_samples: []
type: int64
tags:
- Deprecated
deprecation_message: |
This property is a deprecated variant of `Class.Player.UserId` which
should be used instead.
security:
read: None
write: None
thread_safety: ReadSafe
category: Data
serialization:
can_load: false
can_save: false
capabilities:
- Players
methods:
- name: Player:AddReplicationFocus
summary: |
Adds an additional replication focus for the player.
description: |
This method adds an additional replication focus for the player in order
to trigger streaming around the location of the specified `part`. In this
manner, streaming can occur around multiple locations, not just the
location of `Class.Player.ReplicationFocus`. This has no effect in
experiences that are not streaming enabled.
Additional foci will use the same values of
`Class.Workspace.StreamingMinRadius` and
`Class.Workspace.StreamingTargetRadius` as are used by the primary focus.
This method should only be called on the server. It has no effect when
called from a `Class.LocalScript`.
code_samples: []
parameters:
- name: part
type: BasePart
default:
summary: |
The `Class.BasePart` to use as a new replication focus.
returns:
- type: ()
summary: ''
tags: []
deprecation_message: ''
security: None
thread_safety: Unsafe
capabilities:
- Players
- name: Player:ClearCharacterAppearance
summary: |
Removes all accessories and other character appearance objects from a
player's `Class.Player.Character|Character`.
description: |
This method removes all `Class.Accessory`, `Class.Shirt`, `Class.Pants`,
`Class.CharacterMesh`, and `Class.BodyColors` from the given player's
`Class.Player.Character|Character`. In addition, it also removes the
T-Shirt `Class.Decal` on the player's torso. The character's body part
colors and face will remain unchanged. This method does nothing if the
player does not have a `Class.Player.Character|Character`.
code_samples:
- Player-ClearCharacterAppearance1
parameters: []
returns:
- type: ()
summary: ''
tags: []
deprecation_message: ''
security: None
thread_safety: Unsafe
capabilities:
- Players
- name: Player:DistanceFromCharacter
summary: |
Returns the distance between the character's head and the given
`Datatype.Vector3`, or `0` if the player has no character.
description: |
This method returns the distance between the character's head and the
given `Datatype.Vector3` point, or `0` if the player has no
`Class.Player.Character|Character`.
This is useful when determining the distance between a player and another
object or location in experience.
If you would like to determine the distance between two non-player
instances or positions, you can use the following:
```lua
local distance = (position1 - position2).Magnitude
```
code_samples:
- Player-DistanceFromCharacter1
parameters:
- name: point
type: Vector3
default:
summary: |
The location from which player's distance to is being measured.
returns:
- type: float
summary: |
The distance in studs between the player and the location.
tags: []
deprecation_message: ''
security: None
thread_safety: Unsafe
capabilities:
- Players
- name: Player:GetFriendsOnlineAsync
summary: |
Returns a dictionary of online connections.
description: |
This function returns a dictionary array of online connections, using a 30
second cache. In the returned array, some fields are only present for
certain location types; for example, `PlaceId` won't be present when
`LocationType` is `0` (mobile website).
<table>
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>VisitorId</code></td>
<td>number</td>
<td>The <code>Class.Player.UserId|UserId</code> of the connection.</td>
</tr>
<tr>
<td><code>UserName</code></td>
<td>string</td>
<td>The username of the connection.</td>
</tr>
<tr>
<td><code>DisplayName</code></td>
<td>string</td>
<td>The <code>Class.Player.DisplayName|DisplayName</code> of the connection.</td>
</tr>
<tr>
<td><code>LastOnline</code></td>
<td>string</td>
<td>When the connection was last online.</td>
</tr>
<tr>
<td><code>IsOnline</code></td>
<td>boolean</td>
<td>If the connection is currently online.</td>
</tr>
<tr>
<td><code>LastLocation</code></td>
<td>string</td>
<td>The name of the connection's current location.</td>
</tr>
<tr>
<td><code>PlaceId</code></td>
<td>number</td>
<td>The place ID of the connection's last location.</td>
</tr>
<tr>
<td><code>GameId</code></td>
<td>string</td>
<td>The <code>Class.DataModel.JobId</code> of the connection's last location.</td>
</tr>
<tr>
<td><code>LocationType</code></td>
<td>number</td>
<td>The location type of the connection's last location.</td>
</tr>
</tbody>
</table>
code_samples:
- how-to-get-a-list-of-online-friends
parameters:
- name: maxFriends
type: int
default: 200
summary: |
The maximum number of online connections to return.
returns:
- type: Array
summary: |
A dictionary of online connections (see the table above).
tags:
- Yields
deprecation_message: ''
security: None
thread_safety: Unsafe
capabilities:
- Players
- Social
- name: Player:GetFriendsOnline
summary: |
Returns a dictionary of online connections. Returns the product
information of an asset using its asset ID.
description: ''
code_samples:
- how-to-get-a-list-of-online-friends
parameters:
- name: maxFriends
type: int
default: 200
summary: |
The maximum number of online connections to return.
returns:
- type: Array
summary: |
A dictionary of online connections (see the table above).
tags:
- Yields
- Deprecated
deprecation_message: |
This method has been superseded by
`Class.Player.GetFriendsOnline|GetFriendsOnline()`.
security: None
thread_safety: Unsafe
capabilities:
- Players
- Social
- name: Player:GetJoinData
summary: |
Returns a dictionary containing information describing how the player
joins the experience.
description: |
Returns a dictionary containing information describing how the player
joins the experience. The dictionary contains any of the following fields:
<table>
<thead>
<tr>
<th>Key</th>
<th>Value Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<th><code>SourceGameId</code></th>
<td>number</td>
<td>The <code>Class.DataModel.GameId</code> of the experience the <code>Player</code> teleported from. Only present if the player teleports to the current experience and if a server calls the teleport function.</td>
</tr>
<tr>
<th><code>SourcePlaceId</code></th>
<td>number</td>
<td>The <code>Class.DataModel.PlaceId</code> of the place the <code>Player</code> teleported from. Only present if the player teleports to the current place and a server calls the teleport function.</td>
</tr>
<tr>
<th><code>ReferredByPlayerId</code></th>
<td>number</td>
<td>The <code>Class.Player.UserId|UserId</code> of the player who invited the current player to the experience. Use this data to identify the referrer and trigger reward logic.</td>
</tr>
<tr>
<th><code>Members</code></th>
<td>array</td>
<td>An array containing the <code>Class.Player.UserId|UserId</code> numbers of the users teleported alongside the player. Only present if the player teleported as part of a group.</td>
</tr>
<tr>
<th><code>TeleportData</code></th>
<td>variant</td>
<td>Reflects the <code>teleportData</code> specified in the original teleport. Useful for sharing information between servers the player teleports to. Only present if <code>teleportData</code> was specified and a server calls the teleport function.</td>
</tr>
<tr>
<th><code>LaunchData</code></th>
<td>string</td>
<td>A plain or JSON encoded string that contains launch data specified in a <a href="../../../production/promotion/share-links.md">share link</a> or
<code>Class.ExperienceInviteOptions.LaunchData</code>.</td>
</tr>
<tr>
<th><code>GameJoinContext</code></th>
<td>dictionary</td>
<td>
A dictionary that includes relevant information based on the context of the join. It contains the following keys:<br /><br />
<ul>
<li><code>JoinSource</code>: <code>Enum.JoinSource</code></li>
<li><code>ItemType</code>: optional <code>Enum.AvatarItemType</code></li>
<li><code>AssetId</code>: optional <code>string</code></li>
<li><code>OutfitId</code>: optional <code>string</code></li>
<li><code>AssetType</code>: optional <code>Enum.AssetType</code></li>
</ul>
</td>
</tr>
</tbody>
</table>
If a server initiates the player's teleport, the dictionary that this
method returns includes the player's teleport data. The
`Class.Player:GetJoinData()|GetJoinData()` method can only be used to
fetch teleport data on the server. To fetch the data on the client, use
`Class.TeleportService:GetLocalPlayerTeleportData()`.
Unlike `Class.TeleportService:GetLocalPlayerTeleportData()`,
`Class.Player:GetJoinData()|GetJoinData()` only provides teleport data
that meets the following security criteria:
- It's guaranteed to have been sent by a Roblox server in the past 48
hours.
- It's guaranteed to have been sent with this `Class.Player`.
- The `SourcePlaceId` and `SourceGameId` are guaranteed to be the place
and universe the data was sent from. This means you can verify the
teleport data came from an approved place.
As this data is transmitted by the client, it can still potentially be
abused by an exploiter. Sensitive data such as player currency should be
transmitted via a secure solution like
[Memory Stores](../../../cloud-services/memory-stores/index.md).
code_samples:
- Player-GetJoinData-Tracking-Traffic-Sources
- Player-GetJoinData-Referral-Url-Generator
- Player-GetJoinData-Table-as-Launch-Data
- Player-GetJoinData-Decoding-Json-Launch-Data
- server-teleportdata-example
parameters: []
returns:
- type: Dictionary
summary: |
A dictionary containing PlaceId and UserId values (see table in
description).
tags:
- CustomLuaState
deprecation_message: ''
security: None
thread_safety: Unsafe
capabilities:
- Players
- name: Player:GetMouse
summary: |
Returns the mouse being used by the client.
description: |
This method returns the `Class.Mouse` being used by the client. The
player's mouse instance can be used to track user mouse input including
left and right mouse button clicks and movement and location.
Note that `Class.UserInputService` provides additional methods,
properties, and events to track user input, especially for devices that do
not use a mouse.
code_samples: []
parameters: []
returns:
- type: Mouse
summary: ''
tags: []
deprecation_message: ''
security: None
thread_safety: Unsafe
capabilities:
- Input
- Players
- name: Player:GetNetworkPing
summary: |
Returns the round-trip, isolated network latency in seconds.
description: |
Returns the round-trip, isolated network latency of the player in seconds.
"Ping" is a measurement of the time taken for data to be sent from the
client to the server, then back again. It doesn't involve data
deserialization or processing.
For client-side `Class.LocalScript|LocalScripts`, this function can only
be called on the `Class.Players.LocalPlayer`. This function is useful in
identifying and debugging issues that occur in high network latency
scenarios. It's also useful for masking latency, such as adjusting the
speed of throwing animations for projectiles.
code_samples: []
parameters: []
returns:
- type: float
summary: ''
tags: []
deprecation_message: ''
security: None
thread_safety: Safe
capabilities:
- Players
- name: Player:GetRankInGroupAsync
summary: |
Returns the player's rank in the group as an integer.
description: |
This method 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.
This call may not yield the most up-to-date information. If a player
leaves a group while they are in the experience, `GetRankInGroupAsync()`
will still think they're in that group until they leave. However, this
does not happen when used with a `Class.LocalScript` because the method
caches results, so multiple calls of `GetRankInGroupAsync()` on the same
player with the same group ID will yield the same result as when the
method was first called with the given group ID. The caching behavior is
on a per-peer basis: a server does not share the same cache as a client.
When a player joins a group in-experience due to a call to
`Class.GroupService:PromptJoinAsync()`, any cached value for that player
will be cleared on the client where the prompt was shown.
code_samples:
- Player-GetRankInGroup1
parameters:
- name: groupId
type: int64
default:
summary: |
The `groupId` of the specified group.
returns:
- type: int
summary: |
The player's rank in the group.
tags:
- Yields
deprecation_message: ''
security: None
thread_safety: Unsafe
capabilities:
- Players
- Groups
- name: Player:GetRankInGroup
summary: |
Returns the player's rank in the group as an integer.
description: ''
code_samples:
- Player-GetRankInGroup1
parameters:
- name: groupId
type: int64
default:
summary: |
The `groupId` of the specified group.
returns:
- type: int
summary: |
The player's rank in the group.
tags:
- Yields
- Deprecated
deprecation_message: ''
security: None
thread_safety: Unsafe
capabilities:
- Players
- Groups
- name: Player:GetRoleInGroupAsync
summary: |
Returns the player's role in the group as a string, or `Guest` if the
player isn't part of the group.
description: |
This method returns the player's role in the group as a string, or `Guest`
if the player isn't part of the group.
This call may not yield the most up-to-date information. If a player
leaves a group while they are in the experience, `GetRoleInGroupAsync()`
will still think they're in that group until they leave. However, this
does not happen when used with a `Class.LocalScript` because the method
caches results, so multiple calls of `GetRoleInGroupAsync()` on the same
player with the same group ID will yield the same result as when the
method was first called with the given group ID. The caching behavior is
on a per-peer basis: a server does not share the same cache as a client.
When a player joins a group in-experience due to a call to
`Class.GroupService:PromptJoinAsync()`, any cached value for that player
will be cleared on the client where the prompt was shown.
code_samples:
- Player-GetRoleInGroup1
parameters:
- name: groupId
type: int64
default:
summary: |
The group ID of the specified group.
returns:
- type: string
summary: |
The player's role in the specified group, or `Guest` if the player is
not a member.
tags:
- Yields
deprecation_message: ''
security: None
thread_safety: Unsafe
capabilities:
- Players
- Groups
- name: Player:GetRoleInGroup
summary: |
Returns the player's role in the group as a string, or `Guest` if the
player isn't part of the group.
description: ''
code_samples:
- Player-GetRoleInGroup1
parameters:
- name: groupId
type: int64
default:
summary: |
The group ID of the specified group.
returns:
- type: string
summary: |
The player's role in the specified group, or `Guest` if the player is
not a member.
tags:
- Yields
- Deprecated
deprecation_message: |
This method has been superseded by
`Class.Player.GetRoleInGroupAsync|GetRoleInGroup()`.
security: None
thread_safety: Unsafe
capabilities:
- Players
- Groups
- name: Player:HasAppearanceLoaded
summary: |
Returns whether or not the appearance of the player's character has
loaded.
description: |
This method returns whether or not the appearance of the player's
`Class.Player.Character|Character` has loaded. Appearance includes items
such as the player's `Class.Shirt`, `Class.Pants`, and
`Class.Accessory|Accessories`.
This is useful when determining whether a player's appearance has loaded
after they first join the experience, which can be tracked using the
`Class.Players.PlayerAdded` event.
code_samples:
- check-if-a-player-s-appearance-has-loaded
parameters: []
returns:
- type: boolean
summary: |
A boolean indicating whether or not the appearance of the player's
character has loaded.
tags: []
deprecation_message: ''
security: None
thread_safety: Unsafe
capabilities:
- Players
- name: Player:IsBestFriendsWith
summary: |
Returns whether a player is connections with the specified user.
description: |
This function was once used to return whether a player is best friends
with the specified user, but the feature has since been removed.
code_samples: []
parameters:
- name: userId
type: int64
default:
summary: ''
returns:
- type: boolean
summary: ''
tags:
- Yields
- Deprecated
deprecation_message: |
This function is obsolete because the "best friends" feature was removed.
Use `Class.Player:IsFriendsWithAsync()` instead.
security: None
thread_safety: Unsafe
capabilities:
- Players
- name: Player:IsFriendsWithAsync
summary: |
Checks whether a player is a connection of the user with the given
`Class.Player.UserId`.
description: |
This method sends a request to Roblox asking whether a player is a
connection of another user, given the `Class.Player.UserId|UserId` of that
user. This method caches results so multiple calls on the same player with
the same `userId` may not yield the most up-to-date result.
code_samples: []
parameters:
- name: userId
type: int64
default:
summary: |
The `Class.Player.UserId` of the specified player.
returns:
- type: boolean
summary: |
A boolean indicating whether a player is a connection of the specified
user.
tags:
- Yields
deprecation_message: ''
security: None
thread_safety: Unsafe
capabilities:
- Players
- Social
- name: Player:IsFriendsWith
summary: |
Checks whether a player is a connection of the user with the given
`Class.Player.UserId`.
description: ''
code_samples: []
parameters:
- name: userId
type: int64
default:
summary: |
The `Class.Player.UserId` of the specified player.
returns:
- type: boolean
summary: |
A boolean indicating whether a player is a connection of the specified
user.
tags:
- Yields
- Deprecated
deprecation_message: |
This method has been superseded by the `Class.Player:IsFriendsWithAsync()`
method which should be used for new work.
security: None
thread_safety: Unsafe
capabilities:
- Players
- Social
- name: Player:isFriendsWith
summary: ''
description: ''
code_samples: []
parameters:
- name: userId
type: int64
default:
summary: ''
returns:
- type: boolean
summary: ''
tags:
- Yields
- Deprecated
deprecation_message: |
This method has been superseded by the `Class.Player:IsFriendsWithAsync()`
method which should be used for new work.
security: None
thread_safety: Unsafe
capabilities:
- Players
- name: Player:IsInGroupAsync
summary: |
Checks whether a player is a member of a group with the given ID.
description: |
This method sends a request to Roblox asking whether a player is a member
of a group, given the ID of that group.
This call may not yield the most up-to-date information. If a player
leaves a group while they are in the experience, `IsInGroupAsync()` will
still think they're in that group until they leave. However, this does not
happen when used with a `Class.LocalScript` because the method caches
results, so multiple calls of `IsInGroupAsync()` on the same player with
the same group ID will yield the same result as when the method was first
called with the given group ID. The caching behavior is on a per-peer
basis: a server does not share the same cache as a client.
When a player joins a group in-experience due to a call to
`Class.GroupService:PromptJoinAsync()`, any cached value for that player
will be cleared on the client where the prompt was shown.
code_samples: []
parameters:
- name: groupId
type: int64
default:
summary: |
The group ID of the specified group.
returns:
- type: boolean
summary: |
A boolean indicating whether the player is in the specified group.
tags:
- Yields
deprecation_message: ''
security: None
thread_safety: Unsafe
capabilities:
- Players
- Groups
- name: Player:IsInGroup
summary: |
Checks whether a player is a member of a group with the given ID.
description: ''
code_samples: []
parameters:
- name: groupId
type: int64
default:
summary: |
The group ID of the specified group.
returns:
- type: boolean
summary: |
A boolean indicating whether the player is in the specified group.
tags:
- Yields
- Deprecated
deprecation_message: |
This method has been superseded by
`Class.Player.IsInGroupAsync|IsInGroupAsync()`.
security: None
thread_safety: Unsafe
capabilities:
- Players
- Groups
- name: Player:IsVerified
summary: |
Returns whether the player is verified with concrete, real-world signals.
description: |
Returns a boolean value indicating that player's verification status. When
`true`, the player is verified. Verification includes, but isn't limited
to, non-VOIP phone number or government ID verification.
When implementing `IsVerified`, exercise caution to ensure that the
implementation does not inadvertently block all unverified users.
Note that the method can only be called on the backend server. Calling it
client-side results in an error. Additionally, this method will always
return `false` in Studio.
code_samples:
- Player-IsVerified
parameters: []
returns:
- type: boolean
summary: |
A boolean indicating whether the player is verified.
tags: []
deprecation_message: ''
security: None
thread_safety: Unsafe
capabilities:
- Players
- name: Player:Kick
summary: |
Forcibly disconnect a player from the experience, optionally providing a
message.
description: |
This method allows an experience to gracefully disconnect a client and
optionally provide a message to the disconnected user. This is useful for
moderating abusive users. You should only allow specific users whom you
trust to trigger this method on other users.
Calling this method on a `Class.Player` with no arguments disconnects the
user from the server and provides a default notice message. Calling this
method on a `Class.Player` along with a string as the first argument
replaces the default message with the provided string.
When using this method from a `Class.LocalScript`, only the local user's
client can be kicked.
code_samples: []
parameters:
- name: message
type: string
default:
summary: |
The message to show the user upon kicking.
returns:
- type: ()
summary: ''
tags: []
deprecation_message: ''
security: None
thread_safety: Unsafe
capabilities:
- Players
- Consequences
- name: Player:LoadBoolean
summary: |
Returns a boolean value that was previously saved to the player with
`Class.Player:SaveBoolean()` with the same key.
description: |
This function returns a boolean value that was previously saved to the
player with `Class.Player:SaveBoolean()` with the same key. Returns false
if the key doesn't exist, not `nil`.
code_samples: []
parameters:
- name: key
type: string
default:
summary: ''
returns:
- type: boolean
summary: ''
tags:
- Deprecated
deprecation_message: |
This item is deprecated, as it may have been used for a now obsolete data
persistence method. Please save and load player data using
`Class.DataStoreService` for new work.
security: None
thread_safety: Unsafe
capabilities:
- Players
- name: Player:loadBoolean
summary: ''
description: ''
code_samples: []
parameters:
- name: key
type: string
default:
summary: ''
returns:
- type: boolean
summary: ''
tags:
- Deprecated
deprecation_message: |
This deprecated function is a variant of `Class.Player:LoadBoolean()`
which has also been deprecated. Neither function should be used in new
work.
security: None
thread_safety: Unsafe
capabilities:
- Players
- name: Player:LoadCharacterAsync
summary: |
Creates a new character for the player, removing the old one. Also clears
the player's `Class.Backpack` and `Class.PlayerGui`.
description: |
This method creates a new character for the player, removing the old one.
It also clears the player's `Class.Backpack` and `Class.PlayerGui`. This
is useful in cases where you want to reload the character without killing
the player, such as when you want to load a new character appearance after
changing the player's
`Class.Player.CharacterAppearance|CharacterAppearance`.
After calling `LoadCharacterAsync()` for an individual player, it is not
recommended to call it again for the same player until after that player's
`Class.Player.CharacterAppearanceLoaded|CharacterAppearanceLoaded` event
has fired.
#### Character Loading Event Order
Calling the `LoadCharacterAsync()` method on any `Player` fires events in
the following order:
1. The character appearance initializes.
2. The character rig builds and scales.
3. The character moves to the spawn location.
4. `Class.Player.Character` sets, automatically removing old character.
5. `Class.Object.Changed` fires on the `Class.Player` with a value of
`Character`.
6. The character's `Class.Instance.Parent|Parent` sets to the
`Class.DataModel`.
7. `Class.Player.CharacterAdded` fires.
8. `Class.Player.CharacterAppearanceLoaded` fires.
code_samples:
- Player-LoadCharacter1
parameters: []
returns:
- type: ()
summary: ''
tags:
- Yields
deprecation_message: ''
security: None
thread_safety: Unsafe
capabilities:
- Players
- name: Player:LoadCharacter
summary: |
Creates a new character for the player, removing the old one. Also clears
the player's `Class.Backpack` and `Class.PlayerGui`.
description: ''
code_samples:
- Player-LoadCharacter1
parameters: []
returns:
- type: ()
summary: ''
tags:
- Yields
- Deprecated
deprecation_message: |
This method has been superseded by
`Class.Player:LoadCharacterAsync()|LoadCharacterAsync()`.
security: None
thread_safety: Unsafe
capabilities:
- Players
- name: Player:LoadCharacterAppearance
summary: |
Places the given instance either in the player's character, head, or
StarterGear based on the instance's class.
description: |
The LoadCharacterAppearance `Class.Player` function places the given
instance either in the player's `Class.Player.Character`, head, or
`Class.StarterGear` based on the instance's class.
This is useful when giving a player's character an asset from the Roblox
catalog, such as a hat or piece of gear.
It is similar to `Class.Player:LoadCharacterAsync()`, except it does not
reload the entire character instance, StarterGear, or `Class.PlayerGui`.
Note:
- `Class.Accessory`, `Class.Shirt`, `Class.ShirtGraphic`,
`Class.CharacterMesh`, `Class.BodyColors`, and `Class.Accoutrement` are
parented to the player's character.
- `Class.Decal`, `Class.FileMesh`, `Class.SpecialMesh`, `Class.BlockMesh`,
`Class.CylinderMesh`, and `Class.Texture` are parented to the
character's head.
- `Class.Tool` is parented to the player's `Class.StarterGear`.
- All other classes are ignored.
code_samples:
- Player-LoadCharacterAppearance1
parameters:
- name: assetInstance
type: Instance
default:
summary: |
An instance of the asset being loaded, which can be obtained using the
`Class.InsertService:LoadAsset()` function.
returns:
- type: ()
summary: ''
tags:
- Deprecated
deprecation_message: ''
security: None
thread_safety: Unsafe
capabilities:
- Avatar
- Players
- name: Player:LoadCharacterWithHumanoidDescriptionAsync
summary: |
Spawns a player character with everything equipped in the passed in
`Class.HumanoidDescription`.
description: |
This method spawns a player character with everything equipped in the
passed in `Class.HumanoidDescription`.
After calling this method for an individual player, it is not recommended
to call it again for the same player until after that player's
`Class.Player.CharacterAppearanceLoaded|CharacterAppearanceLoaded` event
has fired.
See also
[HumanoidDescription System](../../../characters/appearance.md#humanoiddescription),
an article which explains the humanoid description system in greater
detail and provides several scripting examples.
code_samples:
- spawn-characters-with-humanoiddescription
parameters:
- name: humanoidDescription
type: HumanoidDescription
default:
summary: |
A `Class.HumanoidDescription` containing traits like body
parts/colors, body scaling, accessories, clothing, and animations that
will be equipped to the loaded character.
returns:
- type: ()
summary: ''
tags:
- Yields
deprecation_message: ''
security: None
thread_safety: Unsafe
capabilities:
- Players
- name: Player:LoadCharacterWithHumanoidDescription
summary: |
Spawns a player character with everything equipped in the passed in
`Class.HumanoidDescription`.
description: ''
code_samples:
- spawn-characters-with-humanoiddescription
parameters:
- name: humanoidDescription
type: HumanoidDescription
default:
summary: |
A `Class.HumanoidDescription` containing traits like body
parts/colors, body scaling, accessories, clothing, and animations that
will be equipped to the loaded character.
returns:
- type: ()
summary: ''
tags:
- Yields
- Deprecated
deprecation_message: |
This method has been superseded by
`Class.Player:LoadCharacterWithHumanoidDescriptionAsync()|LoadCharacterWithHumanoidDescriptionAsync()`.
security: None
thread_safety: Unsafe
capabilities:
- Players
- name: Player:LoadInstance
summary: |
Returns an instance that was previously saved to the player with
`Class.Player:SaveInstance()` with the same key.
description: |
This function returns an instance that was previously saved to the player
with `Class.Player:SaveInstance()` with the same key. Returns `nil` if the
key doesn't exist.
code_samples:
- Player-LoadInstance1
parameters:
- name: key
type: string
default:
summary: ''
returns:
- type: Instance
summary: ''
tags:
- Deprecated
deprecation_message: |
This item is deprecated, as it may have been used for a now obsolete data
persistence method. Please save and load player data using
`Class.DataStoreService` for new work.
security: None
thread_safety: Unsafe
capabilities:
- Players
- name: Player:loadInstance
summary: ''
description: ''
code_samples: []
parameters:
- name: key
type: string
default:
summary: ''
returns:
- type: Instance
summary: ''
tags:
- Deprecated
deprecation_message: |
This deprecated function is a variant of `Class.Player:LoadInstance()`
which has also been deprecated. Neither function should be used in new
work.
security: None
thread_safety: Unsafe
capabilities:
- Players
- name: Player:LoadNumber
summary: |
Returns a number value that was previously saved to the player.
description: |
This function was once used by an ancient data persistence method to
return a number value that was previously saved to the player with
`Class.Player:SaveNumber()` with the same key. Returns 0 if the key
doesn't exist, not `nil`.
code_samples:
- Player-LoadNumber1
parameters:
- name: key
type: string
default:
summary: ''
returns:
- type: double
summary: ''
tags:
- Deprecated
deprecation_message: |
This item is deprecated, as it may have been used for a now obsolete data
persistence method. Please save and load player data using
`Class.DataStoreService` for new work.
security: None
thread_safety: Unsafe
capabilities:
- Players
- name: Player:loadNumber
summary: ''
description: ''
code_samples: []
parameters:
- name: key
type: string
default:
summary: ''
returns:
- type: double
summary: ''
tags:
- Deprecated
deprecation_message: |
This deprecated function is a variant of `Class.Player:LoadNumber()` which
has also been deprecated. Neither function should be used in new work.
security: None
thread_safety: Unsafe
capabilities:
- Players
- name: Player:LoadString
summary: |
Returns a string value that was previously saved to the player.
description: |
This function returns a string value that was previously saved to the
player with `Class.Player:SaveString()` with the same key. Returns an
empty string ("") if the key doesn't exist, not `nil`.
code_samples:
- Player-LoadString1
parameters:
- name: key
type: string
default:
summary: ''
returns:
- type: string
summary: ''
tags:
- Deprecated
deprecation_message: |
This item is deprecated, as it may have been used for a now obsolete data
persistence method. Please save and load player data using
`Class.DataStoreService` for new work.
security: None
thread_safety: Unsafe
capabilities:
- Players
- name: Player:loadString
summary: ''
description: ''
code_samples: []
parameters:
- name: key
type: string
default:
summary: ''
returns:
- type: string
summary: ''
tags:
- Deprecated
deprecation_message: |
This function is a deprecated variant of `Class.Player:LoadString()` which
has also been deprecated. Neither function should be used in new work.
security: None
thread_safety: Unsafe
capabilities:
- Players
- name: Player:Move
summary: |
Causes the player's character to walk in the given direction until
stopped, or interrupted by the player (by using their controls).
description: |
This method causes the player's character to walk in the given direction
until stopped, or interrupted by the player (by using their controls).
This is useful when scripting NPC `Class.Humanoid|Humanoids` that move
around a map but are not controlled by an actual player's input.
Note that the function's second argument indicates whether the provided
`Datatype.Vector3` should move the player relative to world coordinates
(`false`) or the player's `Class.Camera` (`true`).
code_samples:
- Player-Move1
parameters:
- name: walkDirection
type: Vector3
default:
summary: |
The Vector3 direction that the player should move.
- name: relativeToCamera
type: boolean
default: false
summary: |
A boolean indicating whether the player should move relative to the
player's camera.
returns:
- type: ()
summary: ''
tags: []
deprecation_message: ''
security: None
thread_safety: Unsafe
capabilities:
- Players
- name: Player:RemoveReplicationFocus
summary: |
Removes a previously added replication focus.
description: |
This method removes a replication focus previously added by
`Class.Player:AddReplicationFocus()|AddReplicationFocus(). Has no effect
in experiences that are not streaming enabled.
This method should only be called on the server. It has no effect when
called from a `Class.LocalScript`.
code_samples: []
parameters:
- name: part
type: BasePart
default:
summary: |
The `Class.BasePart` to remove as a replication focus.
returns:
- type: ()
summary: ''
tags: []
deprecation_message: ''
security: None
thread_safety: Unsafe
capabilities:
- Players
- name: Player:RequestStreamAroundAsync
summary: |
Requests that the server stream to the player around the specified
location.
description: |
For experiences where
[instance streaming](../../../workspace/streaming.md) is enabled, requests
that the server stream to the player regions (parts and terrain) around
the specified **X**, **Y**, **Z** location in the 3D world. It is useful
if the experience knows that the player's `Datatype.CFrame` will be set to
the specified location in the near future. Without providing the location
with this call, the player may not have streamed in content for the
destination, resulting in a streaming pause or other undesirable behavior.
The effect of this call will be temporary and there are no guarantees of
what will be streamed in around the specified location. Client memory
limits and network conditions may impact what will be available on the
client.
#### Usage Precaution
Requesting streaming around an area is **not a guarantee** that the
content will be present when the request completes, as streaming is
affected by the client's network bandwidth, memory limitations, and other
factors.
code_samples: []
parameters:
- name: position
type: Vector3
default:
summary: |
World location where streaming is requested.
- name: timeOut
type: double
default: 0
summary: |
Optional timeout for the request, the maximum duration that the engine
attempts to stream regions around the `position` parameter before
abandoning the request. If you don't specify a value, the timeout is
effectively infinite. However, if the client is low on memory, the
engine abandons all streaming requests, even those that are still
within the timeout duration.
returns:
- type: ()
summary: ''
tags:
- Yields
deprecation_message: ''
security: None
thread_safety: Unsafe
capabilities:
- Players
- name: Player:SaveBoolean
summary: |
Used to save a boolean value that can be loaded again at a later time
using `Class.Player:LoadBoolean()`.
description: |
This function is used to save a boolean value that can be loaded again at
a later time using `Class.Player:LoadBoolean()`.
code_samples:
- Player-SaveBoolean1
parameters:
- name: key
type: string
default:
summary: ''
- name: value
type: boolean
default:
summary: ''
returns:
- type: ()
summary: ''
tags:
- Deprecated
deprecation_message: |
This item is deprecated, as it may have been used for a now obsolete data
persistence method. Please save and load player data using
`Class.DataStoreService` for new work.
security: None
thread_safety: Unsafe
capabilities:
- Players
- name: Player:saveBoolean
summary: ''
description: ''
code_samples: []
parameters:
- name: key
type: string
default:
summary: ''
- name: value
type: boolean
default:
summary: ''
returns:
- type: ()
summary: ''
tags:
- Deprecated
deprecation_message: |
This function is a deprecated variant of `Class.Player:SaveBoolean()`
which has also been deprecated. Neither function should be used in new
work.
security: None
thread_safety: Unsafe
capabilities:
- Players
- name: Player:SaveInstance
summary: |
Saves an instance which can be loaded again at a later time.
description: |
This function was once used by an ancient data persistence method to save
an instance which can be loaded again at a later time using
`Class.Player:LoadInstance()`..
code_samples:
- Player-SaveInstance1
parameters:
- name: key
type: string
default:
summary: ''
- name: value
type: Instance
default:
summary: ''
returns:
- type: ()
summary: ''
tags:
- Deprecated
deprecation_message: |
This item is deprecated, as it may have been used for a now obsolete data
persistence method. Please save and load player data using
`Class.DataStoreService` for new work.
security: None
thread_safety: Unsafe
capabilities:
- Players
- name: Player:saveInstance
summary: ''
description: ''
code_samples: []
parameters:
- name: key
type: string
default:
summary: ''
- name: value
type: Instance
default:
summary: ''
returns:
- type: ()
summary: ''
tags:
- Deprecated
deprecation_message: |
This function is a deprecated variant of `Class.Player:SaveInstance()`
which has also been deprecated. Neither function should be used in new
work.
security: None
thread_safety: Unsafe
capabilities:
- Players
- name: Player:SaveNumber
summary: |
Saves a number value that can be loaded again at a later time using.
description: |
This function was once used by an ancient data persistence method to save
a number value that can be loaded again at a later time using
`Class.Player:LoadNumber()`.
code_samples:
- Player-SaveNumber1
parameters:
- name: key
type: string
default:
summary: ''
- name: value
type: double
default:
summary: ''
returns:
- type: ()
summary: ''
tags:
- Deprecated
deprecation_message: |
This item is deprecated, as it may have been used for a now obsolete data
persistence method. Please save and load player data using
`Class.DataStoreService` for new work.
security: None
thread_safety: Unsafe
capabilities:
- Players
- name: Player:saveNumber
summary: ''
description: ''
code_samples: []
parameters:
- name: key
type: string
default:
summary: ''
- name: value
type: double
default:
summary: ''
returns:
- type: ()
summary: ''
tags:
- Deprecated
deprecation_message: |
This function is a deprecated variant of `Class.Player:SaveNumber()` which
has also been deprecated. Neither function should be used in new work.
security: None
thread_safety: Unsafe
capabilities:
- Players
- name: Player:SaveString
summary: |
Saves a string value that can be loaded again at a later time.
description: |
This function was once used by an ancient data persistence method to save
a string value that can be loaded again at a later time using
`Class.Player:LoadString()`.
code_samples:
- Player-SaveString1
parameters:
- name: key
type: string
default:
summary: ''
- name: value
type: string
default:
summary: ''
returns:
- type: ()
summary: ''
tags:
- Deprecated
deprecation_message: |
This item is deprecated, as it may have been used for a now obsolete data
persistence method. Please save and load player data using
`Class.DataStoreService` for new work.
security: None
thread_safety: Unsafe
capabilities:
- Players
- name: Player:saveString
summary: ''
description: ''
code_samples: []
parameters:
- name: key
type: string
default:
summary: ''
- name: value
type: string
default:
summary: ''
returns:
- type: ()
summary: ''
tags:
- Deprecated
deprecation_message: |
This function is a deprecated variant of `Class.Player:SaveString()` which
has also been deprecated. Neither function should be used in new work.
security: None
thread_safety: Unsafe
capabilities:
- Players
- name: Player:SetAccountAge
summary: |
Sets the `Class.Player.AccountAge|AccountAge` of the player.
description: |
This method sets the `Class.Player.AccountAge|AccountAge` of the player in
days, meaning the age of the account itself relative to when it was first
created.
code_samples: []
parameters:
- name: accountAge
type: int
default:
summary: |
The age of the account in days.
returns:
- type: ()
summary: ''
tags: []
deprecation_message: ''
security: PluginSecurity
thread_safety: Unsafe
capabilities:
- Players
- name: Player:SetSuperSafeChat
summary: |
Sets whether or not the player sees filtered chats, rather than normal
chats.
description: |
This method sets whether or not the player sees chat filtered by
`Class.TextService:FilterStringAsync()` rather than normal chats.
```lua
local Players = game:GetService("Players")
local player = Players.LocalPlayer
player:SetSuperSafeChat(true)
```
Regardless of whether a player has filtered chat enabled, all chat should
be filtered by `Class.TextService` when broadcast to other players or on
the player's own screen. `Class.TextService:FilterStringAsync()` returns a
`Class.TextFilterResult` object that can be filtered differently according
to the message's intended use.
code_samples: []
parameters:
- name: value
type: boolean
default:
summary: |
A boolean indicating whether or not the player sees filtered chat.
returns:
- type: ()
summary: ''
tags: []
deprecation_message: ''
security: PluginSecurity
thread_safety: Unsafe
capabilities:
- Players
- name: Player:WaitForDataReady
summary: |
Used to pause the script until the player's data is available to
manipulate, or until a certain amount of time has elapsed without fetching
the player's data.
description: |
This function is used to pause the script until the player's data is
available to manipulate, or until a certain amount of time has elapsed
without fetching the player's data
code_samples: []
parameters: []
returns:
- type: boolean
summary: ''
tags:
- Yields
- Deprecated
deprecation_message: |
This item is deprecated, as it may have been used for a now obsolete data
persistence method. Please save and load player data using
`Class.DataStoreService` for new work.
security: None
thread_safety: Unsafe
capabilities:
- Players
- name: Player:waitForDataReady
summary: ''
description: ''
code_samples: []
parameters: []
returns:
- type: boolean
summary: ''
tags:
- Yields
- Deprecated
deprecation_message: |
This function is a deprecated variant of `Class.Player:WaitForDataReady()`
which has also been deprecated. Neither function should be used in new
work.
security: None
thread_safety: Unsafe
capabilities:
- Players
events:
- name: Player.CharacterAdded
summary: |
Fires when a player's character spawns or respawns.
description: |
This event fires when a player's character spawns or respawns. It fires
soon after setting `Class.Player.Character|Character` to a non-`nil` value
or calling `Class.Player:LoadCharacterAsync()|LoadCharacterAsync()`, which
is before the character is parented to the `Class.Workspace`.
This can be used alongside the
`Class.Player.CharacterRemoving|CharacterRemoving` event which fires right
before a player's character is about to be removed, typically after death.
As such, both of these events can potentially fire many times as players
die then respawn in a place.
Note that the `Class.Humanoid` and its default body parts (head, torso,
and limbs) will exist on the server when this event fires, but clothing
items like `Class.Hat|Hats`, `Class.Shirt|Shirts`, and `Class.Pants` might
take a few seconds to be added to the character. The parts will also take
time to replicate to clients. Connect `Class.Instance.ChildAdded` on the
added character to detect these, or wait for the
`Class.Player.CharacterAppearanceLoaded|CharacterAppearanceLoaded` event
to be sure the character has everything equipped.
If you instead need to track when a player joins/leaves the experience,
use the events `Class.Players.PlayerAdded` and
`Class.Players.PlayerRemoving`.
code_samples:
- spawns-and-despawns
- accessory-remover
parameters:
- name: character
type: Model
default:
summary: |
An instance of the character that spawned/respawned.
tags: []
deprecation_message: ''
security: None
capabilities:
- Players
- name: Player.CharacterAppearanceLoaded
summary: |
Fires when the full appearance of a `Class.Player.Character|Character` has
been inserted.
description: |
This event fires when the full appearance of a
`Class.Player.Character|Character` has been inserted. It only fires on the
server.
A `Class.Player.Character|Character` generally has a range of objects
modifying its appearance, including `Class.Accoutrement|Accoutrements`,
`Class.Shirt|Shirts`, `Class.Pants` and
`Class.CharacterMesh|CharacterMeshes`. This event will fire when all such
objects have been inserted into the character.
For custom character implementations, such as using a character model
named `StarterCharacter` inside `Class.StarterPlayer`, use
`Class.Player.CharacterAdded|CharacterAdded` and handle your own
accessories.
One use for this event is to ensure all accessories have loaded before
destroying them. See below for an example of this.
code_samples:
- remove-accessories-after-loading
parameters:
- name: character
type: Model
default:
summary: |
The `Class.Player.Character` `Class.Model`.
tags: []
deprecation_message: ''
security: None
capabilities:
- Players
- name: Player.CharacterRemoving
summary: |
Fires right before a player's character is removed.
description: |
This event fires right before a player's
`Class.Player.Character|Character` is removed, such as when the player is
respawning. This can be used alongside the
`Class.Player.CharacterAdded|CharacterAdded` event which fires when a
player's character spawns or respawns.
If you instead need to track when a player joins/leaves the experience,
use the events `Class.Players.PlayerAdded` and
`Class.Players.PlayerRemoving`.
code_samples:
- spawns-and-despawns
parameters:
- name: character
type: Model
default:
summary: |
An instance of the character that is being removed.
tags: []
deprecation_message: ''
security: None
capabilities:
- Players
- name: Player.Chatted
summary: |
Fires when a player chats in experience using Roblox's provided chat bar.
description: |
This event fires when a `Class.Player` types a message and presses
<kbd>Enter</kbd> in Roblox's provided chat bar. This is done using some
Luau bindings by the default chat script. You can prevent players from
chatting by using `Class.StarterGui:SetCoreGuiEnabled()` and setting
`Enum.CoreGuiType.Chat` to `false`.
code_samples: []
parameters:
- name: message
type: string
default:
summary: |
The content of the message the player typed in chat.
- name: recipient
type: Player
default:
summary: |
**Deprecated.** For whisper messages, this was the Player who was the
intended target of the chat message.
tags: []
deprecation_message: ''
security: None
capabilities:
- Chat
- Players
- name: Player.Idled
summary: |
This event fires approximately two minutes after the engine classifies the
player as idle. Time is the number of seconds that have elapsed since that
point.
description: |
This event fires approximately two minutes after the engine classifies the
player as idle. Time is the number of seconds that have elapsed since that
point. The event continues to fire every 30 seconds for as long as the
player remains idle.
This event only fires in client scripts, not server scripts; use a
`Class.RemoteEvent` to notify the server of idle players.
Roblox automatically disconnects players that have been idle for at least
20 minutes, so this event is useful for warning players that they will be
disconnected soon, disconnecting players prior to those 20 minutes, or
other away from keyboard (AFK) features.
To track how often automatic disconnects occur, try correlating this event
with occurrences of `Class.Players.PlayerRemoving`.
code_samples: []
parameters:
- name: time
type: double
default:
summary: |
The time in seconds the player has been idle.
tags: []
deprecation_message: ''
security: None
capabilities:
- Players
- name: Player.OnTeleport
summary: |
Fires when the teleport state of a player changes.
description: |
This event fires when the `Enum.TeleportState` of a player changes. This
event is useful for detecting whether a teleportation was successful.
code_samples:
- Player-OnTeleport1
parameters:
- name: teleportState
type: TeleportState
default:
summary: |
The new `Enum.TeleportState` of the `Class.Player`.
- name: placeId
type: int64
default:
summary: |
The ID of the place the `Class.Player` is being teleported to.
- name: spawnName
type: string
default:
summary: |
The name of the spawn to teleport to, if
`Class.TeleportService:TeleportToSpawnByName()` has been used.
tags: []
deprecation_message: ''
security: None
capabilities:
- Players
- Teleport
callbacks: []