Class
Player
An object that represents a presently connected client to the experience.
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 a 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 current
Playerobjects usingPlayers:GetPlayers(); again, use this instead ofInstance:GetChildren(). - To detect the addition of
Playerobjects, it is recommended to use thePlayers.PlayerAddedevent (instead ofInstance.ChildAddedon thePlayersservice). - Similarly, you can detect the removal of
Playerobjects usingPlayers.PlayerRemoving, which fires just before thePlayeris removed (instead ofInstance.ChildRemovedwhich fires after). This is important if you are saving information about the player that might be removed or cleaned up on removal.
Properties 40#
AccountAgeint | Describes the player's account age in days.ReadSafeReadOnlyNotReplicated |
AgeCheckedAgeCheckStatus | Indicates whether the player has completed an age verification check.Write: RobloxEngineSecurityReadSafe |
AutoJumpEnabledboolean | Determines whether the character of a player using a mobile device will automatically jump upon hitting an obstacle.ReadSafe |
CameraMaxZoomDistancefloat | The maximum distance the player's camera is allowed to zoom out.ReadSafe |
CameraMinZoomDistancefloat | The minimum distance the player's camera is allowed to zoom in.ReadSafe |
CameraModeCameraMode | Changes the camera's mode to either first or third person.ReadSafe |
CanLoadCharacterAppearanceboolean | Determines whether the character's appearance will be loaded when the
player spawns. If false, the player will spawn with a default
appearance.ReadSafe |
CharacterModel | A Model controlled by the player that contains a Humanoid,
body parts, scripts, and other objects.ReadSafe |
CharacterAppearancestring | The URL of the asset containing the character's appearance, clothing, and gear.ReadSafeDeprecatedNotBrowsable |
CharacterAppearanceIdint64 | Determines the user ID of the account whose character appearance is used
for a player's Character.ReadSafe |
DataComplexityint | The total amount of data currently being stored in the player's cache on the current place.ReadSafeDeprecatedHiddenReadOnlyNotReplicated |
DataReadyboolean | Indicates when the player's data is available to load.ReadSafeDeprecatedHiddenReadOnlyNotReplicated |
DevCameraOcclusionModeDevCameraOcclusionMode | Sets how the default camera handles objects between the camera and the player.ReadSafe |
DevComputerCameraModeDevComputerCameraMovementMode | Determines player's camera movement mode when using a device with a mouse and keyboard.ReadSafe |
DevComputerMovementModeDevComputerMovementMode | Determines player's character movement mode when using a device with a mouse and keyboard.ReadSafe |
DevEnableMouseLockboolean | Determines if the player can toggle mouse lock.ReadSafe |
DevTouchCameraModeDevTouchCameraMovementMode | Determines player's camera movement mode when using a touch-enabled device.ReadSafe |
DevTouchMovementModeDevTouchMovementMode | Determines player's character movement mode when using a touch-enabled device.ReadSafe |
DisplayNamestring | The display name of the authenticated user associated with the
Player.ReadSafe |
FollowUserIdint64 | Describes the user ID of the player who was followed into an experience by a player.ReadSafeReadOnlyNotReplicated |
FrustumStreamingFrustumStreamingMode | Controls the engine's instance streaming behavior for the player's camera view.ReadSafe |
GameplayPausedboolean | Whether player client-side gameplay is currently paused.Write: NotAccessibleSecurityReadSafeHidden |
HasRobloxSubscriptionboolean | Indicates whether the player has an active Roblox subscription.Write: RobloxEngineSecurityReadSafe |
HasVerifiedBadgeboolean | Indicates if a player has a Verified badge.ReadSafe |
HealthDisplayDistancefloat | Sets the distance at which this player will see other players' health bars.ReadSafe |
InputLatencyint | Latency used by the Server Authority netcode system.Read: RobloxEngineSecurityWrite: RobloxEngineSecurityReadSafe |
LocaleIdstring | This property shows the locale ID that the local player has set for their Roblox account.ReadSafeHiddenReadOnlyNotReplicated |
MembershipTypeMembershipType | Describes the account's membership type.ReadSafeDeprecatedReadOnlyNotReplicated |
NameDisplayDistancefloat | Sets the distance at which this player will see other players' names.ReadSafe |
Neutralboolean | Determines whether the player is on a specific team.ReadSafe |
PartyIdstring | A unique identifier of the party a Player belongs to.Write: RobloxEngineSecurityReadSafeHiddenNotReplicated |
ReplicationFocusInstance | Sets the part to focus replication around.ReadSafe |
RespawnLocationSpawnLocation | If set, the player will respawn at the given SpawnLocation.ReadSafe |
StepIdOffsetint | Offset between client and server used by the Server Authority system.Read: RobloxEngineSecurityWrite: RobloxEngineSecurityReadSafe |
TeamTeam | Determines the Team with which the player is associated.ReadSafeNotReplicated |
TeamColorBrickColor | Determines the Team with which the player is associated with
according to that team's Team.TeamColor.ReadSafe |
ThirdPartyTextChatRestrictionStatusChatRestrictionStatus | A read-only value reflecting the player's text-chat restriction status as reported by a third-party platform.Read: RobloxScriptSecurityWrite: RobloxScriptSecurityReadSafeReadOnlyNotReplicated |
UserUser | The User representing this player's domain-scoped identity
within the current experience.Write: RobloxEngineSecurityReadSafe |
UserIdint64 | A unique identifying integer assigned to all user accounts.ReadSafe |
userIdint64 | ReadSafeDeprecated |
AccountAge: int#
ReadOnlyNotReplicatedReadSafe
This property describes how long ago a player's account was registered in
days. It is set using the SetAccountAge()
method, which cannot be accessed by scripts.
AgeChecked: AgeCheckStatus#
Write: RobloxEngineSecurityReadSafe
This read-only property holds an AgeCheckStatus value indicating
whether the player has completed age verification. The default value is
AgeCheckStatus.Unchecked. It transitions to
AgeCheckStatus.Checked when the player passes age verification
through the Player:PromptAgeCheck() flow.
This property is set by the server and cannot be changed by scripts.
AutoJumpEnabled: boolean#
ReadSafe
This property determines whether the Character of
a 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
StarterPlayer.AutoJumpEnabled value determines the initial state
of this property. Then, this property determines the value of the
Humanoid.AutoJumpEnabled property of the
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.
CameraMaxZoomDistance: float#
ReadSafe
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
StarterPlayer.CameraMaxZoomDistance. If this value is set to a
lower value than
CameraMinZoomDistance, it will be
increased to CameraMinZoomDistance.
CameraMinZoomDistance: float#
ReadSafe
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
StarterPlayer.CameraMinZoomDistance. If this value is set to a
higher value than
CameraMaxZoomDistance, it will be
decreased to CameraMaxZoomDistance.
CameraMode: CameraMode#
ReadSafe
This property sets the player's camera mode, defaulting to third person.
Third Person#
In the default third person mode (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 (CameraMode.LockFirstPerson), the player's
camera is zoomed all the way in. Unless there is a visible GUI present
with the 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.
CanLoadCharacterAppearance: boolean#
ReadSafe
This property determines whether the character's appearance will be loaded
when the player spawns. The default value of this property is set by
StarterPlayer.LoadPlayerAppearance.
If
true, the character will load the appearance of the player corresponding to the player'sCharacterAppearanceId.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
LoadCharacterAsync() to load the new
appearance.
Character: Model#
ReadSafe
This property contains a reference to a Model containing a
Humanoid, body parts, scripts, and other objects required for
simulating the player's avatar in-experience. The model is parented to the
Workspace but it may be moved. It is automatically loaded when
Players.CharacterAutoLoads is true and it can be manually loaded
otherwise using LoadCharacterAsync().
Initially this property is nil and it is set when the player's character
first spawns. Use the CharacterAdded event
to detect when a player's character properly loads, and the
CharacterRemoving event to detect when
the character is about to despawn. Avoid using
Object:GetPropertyChangedSignal() on this property.
Note that LocalScripts that are cloned from
StarterGui or StarterPack into a player's
PlayerGui or Backpack respectively are often run before
the old character model is replaced, so Player.Character may refer
to the old model whose Parent property is nil.
Therefore, in a LocalScript under StarterGui or
StarterPack, it is advisable to make sure the parent of
Character is not nil before using it, for example:
CharacterAppearance: string#
NotBrowsableDeprecatedReadSafeDeprecated
Deprecated. This item is deprecated. Do not use it for new work.
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
LoadCharacterAsync() to load the new
appearance.
CharacterAppearanceId: int64#
ReadSafe
This property determines the user ID of the account whose character
appearance is used for a player's Character. By
default, this property is the 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
StarterPlayer.LoadCharacterAppearance property.
DataComplexity: int#
HiddenReadOnlyNotReplicatedDeprecatedReadSafeDeprecated
Deprecated. This item is deprecated, as it may have been used for a now obsolete data
persistence method. Please save and load player data using
DataStoreService for new work.
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
nilfor 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.
DataReady: boolean#
HiddenReadOnlyNotReplicatedDeprecatedReadSafeDeprecated
Deprecated. This item is deprecated, as it may have been used for a now obsolete data
persistence method. Please save and load player data using
DataStoreService for new work.
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.
DevCameraOcclusionMode: DevCameraOcclusionMode#
ReadSafe
Defines how the default camera scripts handle objects between the camera
and the camera subject. Set by
StarterPlayer.DevCameraOcclusionMode and can't be changed for
individual players.
The default value is Zoom. See
DevCameraOcclusionMode for a list of available modes.
DevComputerCameraMode: DevComputerCameraMovementMode#
ReadSafe
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 LocalScript (it must be set on the server using a
Script).
The default value of this property is determined by
StarterPlayer.DevComputerCameraMovementMode.
This property doesn't affect players using a
TouchEnabled device. See
DevTouchCameraMode instead.
DevComputerMovementMode: DevComputerMovementMode#
ReadSafe
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 LocalScript (it must be set on the server
using a Script).
The default value of this property is determined by
StarterPlayer.DevComputerMovementMode.
This property doesn't affect players using a
TouchEnabled device. See
DevTouchMovementMode instead.
DevEnableMouseLock: boolean#
ReadSafe
This property determines if a player is able to toggle mouse lock by
pressing Shift. 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 StarterPlayer.EnableMouseLockOption. This can be set
server-side during runtime by using a 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
Character, and the character will face the same
direction as the Camera. It also offsets the camera view just over
the right shoulder of the player's character.
DevTouchCameraMode: DevTouchCameraMovementMode#
ReadSafe
This property determines the manner in which a player moves their camera
when using a TouchEnabled device.
This property cannot be set using a LocalScript (it must be set on
the server using a Script).
The default value of this property is determined by
StarterPlayer.DevTouchCameraMovementMode.
This property doesn't affect players who aren't using a
TouchEnabled device. See
DevComputerCameraMode instead.
DevTouchMovementMode: DevTouchMovementMode#
ReadSafe
This property determines the manner in which a player moves their
character when using a TouchEnabled
device. This property cannot be set using a LocalScript (it must
be set on the server using a Script).
The default value of this property is determined by
StarterPlayer.DevTouchMovementMode.
This property doesn't affect players who aren't using a
TouchEnabled device. See
DevComputerMovementMode instead.
DisplayName: string#
ReadSafe
This property contains the display name of the authenticated user
associated with the Player object. Unlike
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
UserIdinstead.Characters generated with
LoadCharacterAsync()or by the Roblox engine will have theirHumanoid.DisplayNameproperty assigned to thePlayer.DisplayNameproperty.Display names may have unicode characters in the string. See
UTF-8for more information on how to work with strings with unicode characters.
FollowUserId: int64#
ReadOnlyNotReplicatedReadSafe
This property contains the 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
Players:GetNameFromUserIdAsync() method.
FrustumStreaming: FrustumStreamingMode#
ReadSafe
This property controls the engine's instance streaming behavior for the
camera view of the given player. Enabled means
the player will always stream their camera view.
Automatic means the engine will decide to
stream the camera view based on the player's capability (based on the
bandwidth, device memory, etc.) and gameplay suitability.
Disabled means the player will never stream
their camera view. Default currently behaves
the same as Disabled.
GameplayPaused: boolean#
HiddenWrite: NotAccessibleSecurityReadSafe
This property indicates if the player is currently in a pause state in a
place with StreamingEnabled activated.
It is set on the client but replicated to the server.
See Also#
Workspace.StreamingEnabledwhich controls whether content streaming is enabledWorkspace.StreamingIntegrityModeandStreamingIntegrityModefor more details on when gameplay is paused.
HasRobloxSubscription: boolean#
Write: RobloxEngineSecurityReadSafe
This read-only property is true when the player has an active Roblox
subscription (the flagship Roblox membership), and false otherwise. It
is set by the server and cannot be changed by scripts.
Use this property instead of Player.MembershipType to check for
the Roblox subscription.
HasVerifiedBadge: boolean#
ReadSafe
This property indicates if the player has a Verified badge.
HealthDisplayDistance: float#
ReadSafe
This property sets the distance in studs at which this player will see
other Humanoid health bars. If set to 0, the health bars will
not be displayed. This property is set to
StarterPlayer.HealthDisplayDistance by default.
If a humanoid's health bar is visible, you can set the display type using
Humanoid.DisplayDistanceType.
InputLatency: int#
Read: RobloxEngineSecurityWrite: RobloxEngineSecurityReadSafe
Latency used by the Server Authority netcode system. This property is not accessible through scripts.
LocaleId: string#
HiddenReadOnlyNotReplicatedReadSafe
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 LocalizationService.RobloxLocaleId, the locale ID used
for localizing internal content. This can be a different value when the
player's account locale isn't supported for internal content localization.
MembershipType: MembershipType#
ReadOnlyNotReplicatedReadSafeDeprecated
Deprecated. This property is deprecated. Use Player.HasRobloxSubscription to
check whether a player has an active Roblox subscription.
This property can only be read from to determine membership (it cannot be
set to another membership type). It holds a MembershipType enum of
the account's membership type.
NameDisplayDistance: float#
ReadSafe
This property sets the distance in studs at which this player will see
other Humanoid names. If the property is set to 0, names are
hidden. This property is set to StarterPlayer.NameDisplayDistance
by default.
If a humanoid's name is visible, you can set the display type using
Humanoid.DisplayDistanceType.
Neutral: boolean#
ReadSafe
This property determines whether the player is on a specific team.
PartyId: string#
HiddenNotReplicatedWrite: RobloxEngineSecurityReadSafe
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 SocialService:GetPlayersByPartyId() and
SocialService:GetPartyAsync() to access information about a
player's party and its members.
To test this service in your experience, use the Party Simulator in Roblox Studio or publish the experience and play it in the Roblox application.
ReplicationFocus: Instance#
ReadSafe
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
PrimaryPart as the replication focus.
This property should only be set on the server with a Script, not
a LocalScript. Note that this property does not change or update
network ownership of parts.
RespawnLocation: SpawnLocation#
ReadSafe
If set, the player will respawn at the given SpawnLocation which
must meet the following criteria:
Descendant of
Workspace.The
SpawnLocation.TeamColorproperty is set to the player'sTeamColoror theSpawnLocation.Neutralproperty is set totrue.
Alternatives#
- A
Playerwill spawn fromSpawnLocationsbelonging to their team. In some cases it may be simpler to change the player'sTeaminstead. - Implement your own custom spawn logic using
PVInstance:PivotTo()to manually move theCharacter.
StepIdOffset: int#
Read: RobloxEngineSecurityWrite: RobloxEngineSecurityReadSafe
Offset between client and server used by the Server Authority system. This property is not accessible through scripts.
Team: Team#
NotReplicatedReadSafe
This property is a reference to a Team object within the
Teams service. If the player isn't on a team or has an invalid
TeamColor, this property is nil. When this
property is set, the player has joined the Team and the
Team.PlayerAdded event fires on the associated team. Similarly,
Team.PlayerRemoved fires when the property is unset from a certain
Team.
TeamColor: BrickColor#
ReadSafe
This property determines which Team a player is associated with
according to that team's Team.TeamColor. If no Team object
has the associated BrickColor, the player will not be
associated with a team.
It's often a better idea to set Player.Team to the respective
Team instead of using this property. Setting this property often
leads to repetition of the same BrickColor value for a certain
team across many scripts.
ThirdPartyTextChatRestrictionStatus: ChatRestrictionStatus#
ReadOnlyNotReplicatedRead: RobloxScriptSecurityWrite: RobloxScriptSecurityReadSafe
This read-only property holds the ChatRestrictionStatus that a
third-party platform (for example, a console platform's parental or
communication settings) reports for the player's text chat. The default
value is ChatRestrictionStatus.Unknown.
This property cannot be set from scripts.
User: User#
Write: RobloxEngineSecurityReadSafe
A read-only User value that represents this player's
domain-scoped identity within the current experience. The User
encapsulates the player's domain user ID alongside the domain type and
domain ID, providing an unambiguous identifier that carries its context.
Use this property as the standard way to identify users in new code.
Engine APIs that accept user ID parameters also accept User
values directly.
UserId: int64#
ReadSafe
This property contains a read-only integer that uniquely and
consistently identifies the user's account on Roblox. Unlike the
player's DisplayName which may change, this
value will never change for the same account.
This property is essential when saving/loading player data using
GlobalDataStores.
userId: int64#
DeprecatedReadSafeDeprecated
Deprecated. This property is a deprecated variant of Player.UserId which
should be used instead.
Methods 53#
| AddReplicationFocus | Adds an additional replication focus for the player. |
| ClearCachedAvatarAppearance | Clears the cached avatar appearance for the player, forcing a fresh fetch from the backend on the next respawn. |
| ClearCharacterAppearance | Removes all accessories and other character appearance objects from a
player's Character. |
| DistanceFromCharacter | Returns the distance between the character's head and the given
Vector3, or 0 if the player has no character. |
| GetCameraState | Returns a dictionary containing the player's current camera state.SafeCustomLuaState |
| GetFriendsOnline | Returns a dictionary of online friends.DeprecatedYields |
| GetFriendsOnlineAsync | Returns a dictionary of online friends.Yields |
| GetFriendsWhoPlayedAsync | Returns the user IDs of friends who have previously joined this experience.Yields |
| GetJoinData | Returns a dictionary containing information describing how the player joins the experience.CustomLuaState |
| GetMouse | Returns the mouse being used by the client. |
| GetNetworkPing | Returns the round-trip, isolated network latency in seconds.Safe |
| GetRankInGroup | Returns the player's rank in the group as an integer.DeprecatedYields |
| GetRankInGroupAsync | Returns the player's rank in the group as an integer.DeprecatedYields |
| GetRoleInGroup | Returns the player's role in the group as a string, or Guest if the
player isn't part of the group.DeprecatedYields |
| GetRoleInGroupAsync | Returns the player's role in the group as a string, or Guest if the
player isn't part of the group.DeprecatedYields |
| HasAppearanceLoaded | Returns whether or not the appearance of the player's character has loaded. |
| IsBestFriendsWith | Returns whether a player is friends with the specified user.DeprecatedYields |
| IsFriendsWith | Checks whether a player is a friend of the user with the givenDeprecatedYields |
| isFriendsWith | DeprecatedYields |
| IsFriendsWithAsync | Checks whether a player is a friend of the user with the given
Player.UserId.Yields |
| IsInGroup | Checks whether a player is a member of a group with the given ID.DeprecatedYields |
| IsInGroupAsync | Checks whether a player is a member of a group with the given ID.Yields |
| IsVerified | Returns whether the player meets the specified verification level. |
| Kick | Forcibly disconnect a player from the experience, optionally providing a message. |
| LoadBoolean | Returns a boolean value that was previously saved to the player with
Player:SaveBoolean() with the same key.Deprecated |
| loadBoolean | Deprecated |
| LoadCharacter | Creates a new character for the player, removing the old one. Also clears
the player's Backpack and PlayerGui.DeprecatedYields |
| LoadCharacterAppearance | Places the given instance either in the player's character, head, or StarterGear based on the instance's class.Deprecated |
| LoadCharacterAsync | Creates a new character for the player, removing the old one. Also clears
the player's Backpack and PlayerGui.Yields |
| LoadCharacterWithHumanoidDescription | Spawns a player character with everything equipped in the passed in
HumanoidDescription.DeprecatedYields |
| LoadCharacterWithHumanoidDescriptionAsync | Spawns a player character with everything equipped in the passed in
HumanoidDescription.Yields |
| LoadInstance | Returns an instance that was previously saved to the player with
Player:SaveInstance() with the same key.Deprecated |
| loadInstance | Deprecated |
| LoadNumber | Returns a number value that was previously saved to the player.Deprecated |
| loadNumber | Deprecated |
| LoadString | Returns a string value that was previously saved to the player.Deprecated |
| loadString | Deprecated |
| Move | Causes the player's character to walk in the given direction until stopped, or interrupted by the player (by using their controls). |
| PromptAgeCheck | Prompts the player to complete age verification. |
| RemoveReplicationFocus | Removes a previously added replication focus. |
| RequestStreamAroundAsync | Requests that the server stream to the player around the specified location.Yields |
| SaveBoolean | Used to save a boolean value that can be loaded again at a later time
using Player:LoadBoolean().Deprecated |
| saveBoolean | Deprecated |
| SaveInstance | Saves an instance which can be loaded again at a later time.Deprecated |
| saveInstance | Deprecated |
| SaveNumber | Saves a number value that can be loaded again at a later time using.Deprecated |
| saveNumber | Deprecated |
| SaveString | Saves a string value that can be loaded again at a later time.Deprecated |
| saveString | Deprecated |
| SetAccountAge | Sets the AccountAge of the player.PluginSecurity security |
| SetSuperSafeChat | Sets whether or not the player sees filtered chats, rather than normal chats.PluginSecurity security |
| WaitForDataReady | 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.DeprecatedYields |
| waitForDataReady | DeprecatedYields |
AddReplicationFocus(part: BasePart): ()#
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 Player.ReplicationFocus. This has no effect in
experiences that are not streaming enabled.
Additional foci will use the same values of
Workspace.StreamingMinRadius and
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 LocalScript.
Returns
()
ClearCachedAvatarAppearance(): ()#
This method clears the cached avatar appearance for the player. The next
time LoadCharacterAsync() is called
with the player's default platform appearance, a fresh version will be
fetched from the backend instead of using the cached version.
Avatar appearance is cached after the first load to improve respawn latency and reduce backend load; most players do not change their avatar mid-session. Call this method when you want to reflect a change the player has made to their avatar outside of the experience, for example to implement a custom refresh button that mirrors the behavior of the default in-experience menu.
Returns
()
ClearCharacterAppearance(): ()#
This method removes all Accessory, Shirt, Pants,
CharacterMesh, and BodyColors from the given player's
Character. In addition, it also removes the
T-Shirt 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 Character.
Returns
()
DistanceFromCharacter(point: Vector3): float#
This method returns the distance between the character's head and the
given Vector3 point, or 0 if the player has no
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:
| Name | Type | Default | Description |
|---|---|---|---|
point | Vector3 | The location from which player's distance to is being measured. |
Returns
float— The distance in studs between the player and the location.
GetCameraState(): CameraState#
CustomLuaStateSafe
Returns a dictionary containing information about the player's current camera state. This method requires Server Authority to be enabled in the game. The dictionary contains the following fields:
| Key | Value Type | Description |
|---|---|---|
CFrame |
Datatype.CFrame |
The current Class.Camera.CFrame|CFrame of the player's camera. |
FieldOfView |
number | The current Class.Camera.FieldOfView|FieldOfView of the player's camera in degrees. |
ViewportSize |
Datatype.Vector2 |
The current Class.Camera.ViewportSize|ViewportSize of the player's camera in pixels. |
On the client, this method can only be called on the
Players.LocalPlayer. On the server, it can be called on any
Player object to retrieve their replicated camera state. Typical
server-side uses include aim and look-direction logic in
server-authoritative gameplay, and camera-aware content streaming.
The CFrame field is replicated as part of the player's input stream,
meaning it is synchronized with other inputs such as movement and actions.
The FieldOfView and ViewportSize fields use standard client-to-server
property replication which is not synchronized with input and may update
at a different cadence.
Returns
CameraState— A dictionary containingCFrame,FieldOfView, andViewportSizevalues.
GetFriendsOnline(maxFriends: int = 200): Array#
YieldsDeprecatedDeprecated
Deprecated. This method has been superseded by
GetFriendsOnlineAsync().
This method returns an array describing the
LocalPlayer's currently online friends, up to
a maximum of maxFriends entries. It can only be called on the
Players.LocalPlayer; calling it on any other Player raises
an error. No more than 200 friends are ever returned, and requesting more
logs a warning.
This method has been superseded by
GetFriendsOnlineAsync(), which
shares the same behavior and return format. See that method for the full
description of the returned dictionary array.
| Name | Type | Default | Description |
|---|---|---|---|
maxFriends | int | 200 | The maximum number of online friends to return. |
Returns
Array— A dictionary of online friends (see the table above).
GetFriendsOnlineAsync(maxFriends: int = 200): Array#
Yields
This function returns a dictionary array of online friends, 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).
| Name | Type | Description |
|---|---|---|
VisitorId |
number | The Class.Player.UserId|UserId of the friend. |
UserName |
string | The username of the friend. |
DisplayName |
string | The Class.Player.DisplayName|DisplayName of the friend. |
LastOnline |
string | When the friend was last online. |
IsOnline |
boolean | If the friend is currently online. |
LastLocation |
string | The name of the friend's current location. |
PlaceId |
number | The place ID of the friend's last location. |
GameId |
string | The Class.DataModel.JobId of the friend's last location. |
LocationType |
number | The location type of the friend's last location. |
| Name | Type | Default | Description |
|---|---|---|---|
maxFriends | int | 200 | The maximum number of online friends to return. |
Returns
Array— A dictionary of online friends (see the table above).
GetFriendsWhoPlayedAsync(): Array#
Yields
Returns an array of user IDs of any friends who have previously played
this game. For example, if a player has had two friends play the game, the
method might return {1111111111, 2222222222}. If no friends have played
this game, the method returns an empty array ({}).
This is particularly useful for friend leaderboards: by narrowing DataStore lookups to only friends who have actually played the experience, you avoid fetching scores for the entire friends list and reduce the risk of hitting DataStore rate limits.
Returns
Array— An array of user IDs.
GetJoinData(): Dictionary#
CustomLuaState
Returns a dictionary containing information describing how the player joins the experience. The dictionary contains any of the following fields:
| Key | Value Type | Description |
|---|---|---|
SourceGameId |
number | The Class.DataModel.GameId of the experience the Player teleported from. Only present if the player teleports to the current experience and if a server calls the teleport function. |
SourcePlaceId |
number | The Class.DataModel.PlaceId of the place the Player teleported from. Only present if the player teleports to the current place and a server calls the teleport function. |
ReferredByPlayerId |
number | The Class.Player.UserId|UserId of the player who invited the current player to the experience. Use this data to identify the referrer and trigger reward logic. |
Members |
array | An array containing the Class.Player.UserId|UserId numbers of the users teleported alongside the player. Only present if the player teleported as part of a group. |
TeleportData |
variant | Reflects the teleportData specified in the original teleport. Useful for sharing information between servers the player teleports to. Only present if teleportData was specified and a server calls the teleport function. |
LaunchData |
string | A plain or JSON encoded string that contains launch data specified in a share link or
Class.ExperienceInviteOptions.LaunchData. |
GameJoinContext |
dictionary |
A dictionary that includes relevant information based on the context of the join. It contains the following keys:
|
If a server initiates the player's teleport, the dictionary that this
method returns includes the player's teleport data. The
GetJoinData() method can only be used to
fetch teleport data on the server. To fetch the data on the client, use
TeleportService:GetLocalPlayerTeleportData().
Unlike TeleportService:GetLocalPlayerTeleportData(),
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
Player. - The
SourcePlaceIdandSourceGameIdare 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.
Returns
Dictionary— A dictionary containing PlaceId and UserId values (see table in description).
GetMouse(): Mouse#
This method returns the 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 UserInputService provides additional methods,
properties, and events to track user input, especially for devices that do
not use a mouse.
GetNetworkPing(): float#
Safe
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 LocalScripts, this function can only
be called on the 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.
Returns
float— The round-trip network latency of the player in seconds.
GetRankInGroup(groupId: int64): int#
YieldsDeprecatedDeprecated
Deprecated. This method has been superseded by
GetRankInGroupAsync().
Only public roles are considered.
| Name | Type | Default | Description |
|---|---|---|---|
groupId | int64 | The groupId of the specified group. |
Returns
int— The player's rank in the group.
GetRankInGroupAsync(groupId: int64): int#
YieldsDeprecatedDeprecated
Deprecated. This method returns only the rank value of the member's highest public
role. Use GroupService:GetRolesInGroupAsync() instead, which
returns all public roles.
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.
Only public roles are considered.
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 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
GroupService:PromptJoinAsync(), any cached value for that player
will be cleared on the client where the prompt was shown.
| Name | Type | Default | Description |
|---|---|---|---|
groupId | int64 | The groupId of the specified group. |
Returns
int— The player's rank in the group.
GetRoleInGroup(groupId: int64): string#
YieldsDeprecatedDeprecated
Deprecated. This method has been superseded by
GetRoleInGroup().
Only public roles are considered.
| Name | Type | Default | Description |
|---|---|---|---|
groupId | int64 | The group ID of the specified group. |
Returns
string— The player's role in the specified group, orGuestif the player is not a member.
GetRoleInGroupAsync(groupId: int64): string#
YieldsDeprecatedDeprecated
Deprecated. This method returns only the member's highest public role. Use
GroupService:GetRolesInGroupAsync() instead, which returns all
public roles.
This method returns the player's role in the group as a string, or Guest
if the player isn't part of the group. Only public roles are considered.
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 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
GroupService:PromptJoinAsync(), any cached value for that player
will be cleared on the client where the prompt was shown.
| Name | Type | Default | Description |
|---|---|---|---|
groupId | int64 | The group ID of the specified group. |
Returns
string— The player's role in the specified group, orGuestif the player is not a member.
HasAppearanceLoaded(): boolean#
This method returns whether or not the appearance of the player's
Character has loaded. Appearance includes items
such as the player's Shirt, Pants, and
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
Players.PlayerAdded event.
Returns
boolean— A boolean indicating whether or not the appearance of the player's character has loaded.
IsBestFriendsWith(userId: User): boolean#
YieldsDeprecatedDeprecated
Deprecated. This function is obsolete because the "best friends" feature was removed.
Use Player:IsFriendsWithAsync() instead.
This function was once used to return whether a player is best friends with the specified user, but the feature has since been removed.
| Name | Type | Default | Description |
|---|---|---|---|
userId | User | The Player.UserId of the user to check friendship with. |
Returns
boolean— A boolean indicating whether the player is friends with the specified user.
IsFriendsWith(userId: User): boolean#
YieldsDeprecatedDeprecated
Deprecated. This method has been superseded by the Player:IsFriendsWithAsync()
method which should be used for new work.
This method sends a request to Roblox asking whether the player is a
friend of the user with the given UserId. Results
are cached, so multiple calls on the same player with the same userId
may not reflect the most up-to-date friendship status.
This method has been superseded by
IsFriendsWithAsync(), which shares the
same behavior and should be used for new work.
| Name | Type | Default | Description |
|---|---|---|---|
userId | User | The Player.UserId of the specified player. |
Returns
boolean— A boolean indicating whether a player is a friend of the specified user.
isFriendsWith(userId: User): boolean#
YieldsDeprecatedDeprecated
Deprecated. This method has been superseded by the Player:IsFriendsWithAsync()
method which should be used for new work.
| Name | Type | Default | Description |
|---|---|---|---|
userId | User |
Returns
boolean
IsFriendsWithAsync(userId: User): boolean#
Yields
This method sends a request to Roblox asking whether a player is a friend
of another user, given the 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.
| Name | Type | Default | Description |
|---|---|---|---|
userId | User | The Player.UserId of the specified player. |
Returns
boolean— A boolean indicating whether a player is a friend of the specified user.
IsInGroup(groupId: int64): boolean#
YieldsDeprecatedDeprecated
Deprecated. This method has been superseded by
IsInGroupAsync().
This method sends a request to Roblox asking whether the player is a member of the group with the given ID.
This method has been superseded by
IsInGroupAsync(), which shares the same
behavior (including its per-peer result caching) and should be used for
new work.
| Name | Type | Default | Description |
|---|---|---|---|
groupId | int64 | The group ID of the specified group. |
Returns
boolean— A boolean indicating whether the player is in the specified group.
IsInGroupAsync(groupId: int64): boolean#
Yields
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 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
GroupService:PromptJoinAsync(), any cached value for that player
will be cleared on the client where the prompt was shown.
| Name | Type | Default | Description |
|---|---|---|---|
groupId | int64 | The group ID of the specified group. |
Returns
boolean— A boolean indicating whether the player is in the specified group.
IsVerified(level: VerifiedLevel = Low): boolean#
Returns a boolean value indicating whether the player meets the specified
VerifiedLevel. When level is omitted, this method defaults to
VerifiedLevel.Low. Note that this is a distinct check from the
verified badge.
Verification uses concrete, real-world signals, including, but not limited to, 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.
| Name | Type | Default | Description |
|---|---|---|---|
level | VerifiedLevel | Low | The verification level to check. Defaults to VerifiedLevel.Low. |
Returns
boolean— A boolean indicating whether the player meets the specified verification level.
Kick(message: string): ()#
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 Player with no arguments disconnects the
user from the server and provides a default notice message. Calling this
method on a Player along with a string as the first argument
replaces the default message with the provided string.
When using this method from a LocalScript, only the local user's
client can be kicked.
| Name | Type | Default | Description |
|---|---|---|---|
message | string | The message to show the user upon kicking. |
Returns
()
LoadBoolean(key: string): boolean#
DeprecatedDeprecated
Deprecated. This item is deprecated, as it may have been used for a now obsolete data
persistence method. Please save and load player data using
DataStoreService for new work.
This function returns a boolean value that was previously saved to the
player with Player:SaveBoolean() with the same key. Returns false
if the key doesn't exist, not nil.
| Name | Type | Default | Description |
|---|---|---|---|
key | string | The string key under which the boolean was previously saved. |
Returns
boolean— The saved boolean value, orfalseif the key does not exist.
loadBoolean(key: string): boolean#
DeprecatedDeprecated
Deprecated. This deprecated function is a variant of Player:LoadBoolean()
which has also been deprecated. Neither function should be used in new
work.
| Name | Type | Default | Description |
|---|---|---|---|
key | string |
Returns
boolean
LoadCharacter(): ()#
YieldsDeprecatedDeprecated
Deprecated. This method has been superseded by
LoadCharacterAsync().
This method creates a new Character for the
player, removing the old one, and also clears the player's
Backpack and PlayerGui. It can only be called on the
server.
This method has been superseded by
LoadCharacterAsync(), which shares the
same character-loading behavior and should be used for new work.
Returns
()
LoadCharacterAppearance(assetInstance: Instance): ()#
DeprecatedDeprecated
Deprecated. This method is deprecated. Do not use it for new work.
The LoadCharacterAppearance Player function places the given
instance either in the player's Player.Character, head, or
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 Player:LoadCharacterAsync(), except it does not
reload the entire character instance, StarterGear, or PlayerGui.
Note:
Accessory,Shirt,ShirtGraphic,CharacterMesh,BodyColors, andAccoutrementare parented to the player's character.Decal,FileMesh,SpecialMesh,BlockMesh,CylinderMesh, andTextureare parented to the character's head.Toolis parented to the player'sStarterGear.- All other classes are ignored.
| Name | Type | Default | Description |
|---|---|---|---|
assetInstance | Instance | An instance of the asset being loaded, which can be obtained using the
InsertService:LoadAsset() function. |
Returns
()
LoadCharacterAsync(): ()#
Yields
This method creates a new character for the player, removing the old one.
It also clears the player's Backpack and 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
CharacterAppearance.
When reloading a Player with their default platform appearance
applied, a cached version of their appearance will be loaded. The cached
version is cleared whenever the player's appearance is updated using
AvatarEditorService or when the player manually resets via the
in-experience menu. To programmatically clear this cache, call
ClearCachedAvatarAppearance()
before calling LoadCharacterAsync().
After calling LoadCharacterAsync() for an individual player, it is not
recommended to call it again for the same player until after that player's
CharacterAppearanceLoaded event
has fired.
Character Loading Event Order#
Calling the LoadCharacterAsync() method on any Player fires events in
the following order:
Player.Charactersets, automatically removing old character.Player.CharacterAddedfires.Object.Changedfires on thePlayerwith a value ofCharacter.- The character appearance initializes.
Player.CharacterAppearanceLoadedfires.- The character's
Parentsets to theDataModel. - The character rig builds and scales.
- The character moves to the spawn location.
Returns
()
LoadCharacterWithHumanoidDescription(humanoidDescription: HumanoidDescription, assetTypeVerification: AssetTypeVerification = Default): ()#
YieldsDeprecatedDeprecated
Deprecated. This method has been superseded by
LoadCharacterWithHumanoidDescriptionAsync().
This method spawns a player character with everything equipped in the
passed-in HumanoidDescription, such as body parts, colors, body
scaling, accessories, clothing, and animations. A nil description raises
an error, and a description that contains duplicate costume assets or
duplicate body parts logs a warning before the character loads.
This method has been superseded by
LoadCharacterWithHumanoidDescriptionAsync(),
which shares the same behavior and should be used for new work.
| Name | Type | Default | Description |
|---|---|---|---|
humanoidDescription | HumanoidDescription | A HumanoidDescription containing traits like body
parts/colors, body scaling, accessories, clothing, and animations that
will be equipped to the loaded character. | |
assetTypeVerification | AssetTypeVerification | Default | The asset type verification mode. |
Returns
()
LoadCharacterWithHumanoidDescriptionAsync(humanoidDescription: HumanoidDescription, assetTypeVerification: AssetTypeVerification = Default): ()#
Yields
This method spawns a player character with everything equipped in the
passed in 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
CharacterAppearanceLoaded event
has fired.
See also HumanoidDescription System, an article which explains the humanoid description system in greater detail and provides several scripting examples.
| Name | Type | Default | Description |
|---|---|---|---|
humanoidDescription | HumanoidDescription | A HumanoidDescription containing traits like body
parts/colors, body scaling, accessories, clothing, and animations that
will be equipped to the loaded character. | |
assetTypeVerification | AssetTypeVerification | Default | The asset type verification mode. |
Returns
()
LoadInstance(key: string): Instance#
DeprecatedDeprecated
Deprecated. This item is deprecated, as it may have been used for a now obsolete data
persistence method. Please save and load player data using
DataStoreService for new work.
This function returns an instance that was previously saved to the player
with Player:SaveInstance() with the same key. Returns nil if the
key doesn't exist.
| Name | Type | Default | Description |
|---|---|---|---|
key | string | The string key under which the instance was previously saved. |
loadInstance(key: string): Instance#
DeprecatedDeprecated
Deprecated. This deprecated function is a variant of Player:LoadInstance()
which has also been deprecated. Neither function should be used in new
work.
| Name | Type | Default | Description |
|---|---|---|---|
key | string |
Returns
LoadNumber(key: string): double#
DeprecatedDeprecated
Deprecated. This item is deprecated, as it may have been used for a now obsolete data
persistence method. Please save and load player data using
DataStoreService for new work.
This function was once used by an ancient data persistence method to
return a number value that was previously saved to the player with
Player:SaveNumber() with the same key. Returns 0 if the key
doesn't exist, not nil.
| Name | Type | Default | Description |
|---|---|---|---|
key | string | The string key under which the number was previously saved. |
Returns
double— The saved number value, or0if the key does not exist.
loadNumber(key: string): double#
DeprecatedDeprecated
Deprecated. This deprecated function is a variant of Player:LoadNumber() which
has also been deprecated. Neither function should be used in new work.
| Name | Type | Default | Description |
|---|---|---|---|
key | string |
Returns
double
LoadString(key: string): string#
DeprecatedDeprecated
Deprecated. This item is deprecated, as it may have been used for a now obsolete data
persistence method. Please save and load player data using
DataStoreService for new work.
This function returns a string value that was previously saved to the
player with Player:SaveString() with the same key. Returns an
empty string ("") if the key doesn't exist, not nil.
| Name | Type | Default | Description |
|---|---|---|---|
key | string | The string key under which the string was previously saved. |
Returns
string— The saved string value, or an empty string if the key does not exist.
loadString(key: string): string#
DeprecatedDeprecated
Deprecated. This function is a deprecated variant of Player:LoadString() which
has also been deprecated. Neither function should be used in new work.
| Name | Type | Default | Description |
|---|---|---|---|
key | string |
Returns
string
Move(walkDirection: Vector3, relativeToCamera: boolean = false): ()#
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 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
Vector3 should move the player relative to world coordinates
(false) or the player's Camera (true).
| Name | Type | Default | Description |
|---|---|---|---|
walkDirection | Vector3 | The Vector3 direction that the player should move. | |
relativeToCamera | boolean | false | A boolean indicating whether the player should move relative to the player's camera. |
Returns
()
PromptAgeCheck(): ()#
This method requests that the player be shown the age verification prompt.
When called from a LocalScript, it must target the
Players.LocalPlayer; when called from a server Script, it
can target any Player. Repeated calls for the same player within a
short cooldown window are silently ignored.
On success, the PromptAgeCheckRequested event fires on the target
player's client. When the player passes verification, their
Player.AgeChecked property transitions to
AgeCheckStatus.Checked.
Returns
()
RemoveReplicationFocus(part: BasePart): ()#
This method removes a replication focus previously added by
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 LocalScript.
Returns
()
RequestStreamAroundAsync(position: Vector3, timeOut: double = 0): ()#
Yields
For experiences where
instance streaming 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 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.
| Name | Type | Default | Description |
|---|---|---|---|
position | Vector3 | World location where streaming is requested. | |
timeOut | double | 0 | 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
()
SaveBoolean(key: string, value: boolean): ()#
DeprecatedDeprecated
Deprecated. This item is deprecated, as it may have been used for a now obsolete data
persistence method. Please save and load player data using
DataStoreService for new work.
This function is used to save a boolean value that can be loaded again at
a later time using Player:LoadBoolean().
| Name | Type | Default | Description |
|---|---|---|---|
key | string | The string key to associate with the saved boolean value. | |
value | boolean | The boolean value to save. |
Returns
()
saveBoolean(key: string, value: boolean): ()#
DeprecatedDeprecated
Deprecated. This function is a deprecated variant of Player:SaveBoolean()
which has also been deprecated. Neither function should be used in new
work.
| Name | Type | Default | Description |
|---|---|---|---|
key | string | ||
value | boolean |
Returns
()
SaveInstance(key: string, value: Instance): ()#
DeprecatedDeprecated
Deprecated. This item is deprecated, as it may have been used for a now obsolete data
persistence method. Please save and load player data using
DataStoreService for new work.
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
Player:LoadInstance()..
| Name | Type | Default | Description |
|---|---|---|---|
key | string | The string key to associate with the saved instance. | |
value | Instance | The Instance to save. |
Returns
()
saveInstance(key: string, value: Instance): ()#
DeprecatedDeprecated
Deprecated. This function is a deprecated variant of Player:SaveInstance()
which has also been deprecated. Neither function should be used in new
work.
| Name | Type | Default | Description |
|---|---|---|---|
key | string | ||
value | Instance |
Returns
()
SaveNumber(key: string, value: double): ()#
DeprecatedDeprecated
Deprecated. This item is deprecated, as it may have been used for a now obsolete data
persistence method. Please save and load player data using
DataStoreService for new work.
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
Player:LoadNumber().
| Name | Type | Default | Description |
|---|---|---|---|
key | string | The string key to associate with the saved number value. | |
value | double | The number value to save. |
Returns
()
saveNumber(key: string, value: double): ()#
DeprecatedDeprecated
Deprecated. This function is a deprecated variant of Player:SaveNumber() which
has also been deprecated. Neither function should be used in new work.
| Name | Type | Default | Description |
|---|---|---|---|
key | string | ||
value | double |
Returns
()
SaveString(key: string, value: string): ()#
DeprecatedDeprecated
Deprecated. This item is deprecated, as it may have been used for a now obsolete data
persistence method. Please save and load player data using
DataStoreService for new work.
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
Player:LoadString().
| Name | Type | Default | Description |
|---|---|---|---|
key | string | The string key to associate with the saved string value. | |
value | string | The string value to save. |
Returns
()
saveString(key: string, value: string): ()#
DeprecatedDeprecated
Deprecated. This function is a deprecated variant of Player:SaveString() which
has also been deprecated. Neither function should be used in new work.
| Name | Type | Default | Description |
|---|---|---|---|
key | string | ||
value | string |
Returns
()
SetAccountAge(accountAge: int): ()#
PluginSecurity security
This method sets the AccountAge of the player in
days, meaning the age of the account itself relative to when it was first
created.
| Name | Type | Default | Description |
|---|---|---|---|
accountAge | int | The age of the account in days. |
Returns
()
SetSuperSafeChat(value: boolean): ()#
PluginSecurity security
This method sets whether or not the player sees chat filtered by
TextService:FilterStringAsync() rather than normal chats.
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 TextService when broadcast to other players or on
the player's own screen. TextService:FilterStringAsync() returns a
TextFilterResult object that can be filtered differently according
to the message's intended use.
| Name | Type | Default | Description |
|---|---|---|---|
value | boolean | A boolean indicating whether or not the player sees filtered chat. |
Returns
()
WaitForDataReady(): boolean#
YieldsDeprecatedDeprecated
Deprecated. This item is deprecated, as it may have been used for a now obsolete data
persistence method. Please save and load player data using
DataStoreService for new work.
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
Returns
boolean— A boolean indicating whether the player's data loaded successfully.
waitForDataReady(): boolean#
YieldsDeprecatedDeprecated
Deprecated. This function is a deprecated variant of Player:WaitForDataReady()
which has also been deprecated. Neither function should be used in new
work.
Returns
boolean
Events 6#
| CharacterAdded | Fires when a player's character spawns or respawns. |
| CharacterAppearanceLoaded | Fires when the full appearance of a Character has
been inserted. |
| CharacterRemoving | Fires right before a player's character is removed. |
| Chatted | Fires when a player chats in experience using Roblox's provided chat bar. |
| Idled | 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. |
| OnTeleport | Fires when the teleport state of a player changes. |
CharacterAdded(character: Model)#
This event fires when a player's character spawns or respawns. It fires
soon after setting Character to a non-nil value
or calling LoadCharacterAsync(), which
is before the character is parented to the Workspace.
This can be used alongside the
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 Humanoid and its default body parts (head, torso,
and limbs) will exist on the server when this event fires, but clothing
items like Hats, Shirts, and Pants might
take a few seconds to be added to the character. The parts will also take
time to replicate to clients. Connect Instance.ChildAdded on the
added character to detect these, or wait for the
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 Players.PlayerAdded and
Players.PlayerRemoving.
| Name | Type | Default | Description |
|---|---|---|---|
character | Model | An instance of the character that spawned/respawned. |
CharacterAppearanceLoaded(character: Model)#
This event fires when the full appearance of a
Character has been inserted. It only fires on the
server.
A Character generally has a range of objects
modifying its appearance, including Accoutrements,
Shirts, Pants and
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 StarterPlayer, use
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.
| Name | Type | Default | Description |
|---|---|---|---|
character | Model | The Player.Character Model. |
CharacterRemoving(character: Model)#
This event fires right before a player's
Character is removed, such as when the player is
respawning. This can be used alongside the
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 Players.PlayerAdded and
Players.PlayerRemoving.
| Name | Type | Default | Description |
|---|---|---|---|
character | Model | An instance of the character that is being removed. |
Chatted(message: string, recipient: Player)#
This event fires when a Player types a message and presses
Enter 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 StarterGui:SetCoreGuiEnabled() and setting
CoreGuiType.Chat to false.
| Name | Type | Default | Description |
|---|---|---|---|
message | string | The content of the message the player typed in chat. | |
recipient | Player | Deprecated. For whisper messages, this was the Player who was the intended target of the chat message. |
Idled(time: double)#
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.
Once the player becomes active again, Idled stops firing and the elapsed
idle time resets. There is no separate event for the transition back to
activity. If the player goes idle again later, Idled waits the same ~2
minutes before firing again.
This event only fires in client scripts, not server scripts; use a
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 Players.PlayerRemoving.
| Name | Type | Default | Description |
|---|---|---|---|
time | double | The time in seconds the player has been idle. |
OnTeleport(teleportState: TeleportState, placeId: int64, spawnName: string)#
This event fires when the TeleportState of a player changes. This
event is useful for detecting whether a teleportation was successful.
| Name | Type | Default | Description |
|---|---|---|---|
teleportState | TeleportState | The new TeleportState of the Player. | |
placeId | int64 | The ID of the place the Player is being teleported to. | |
spawnName | string | The name of the spawn to teleport to, if
TeleportService:TeleportToSpawnByName() has been used. |
Inherited members#
Inherited from Instance 58
Properties (10)
Archivable, archivable, Capabilities, IsInSandbox, Name, Parent, PredictionMode, RobloxLocked, Sandboxed, UniqueId
Methods (39)
AddTag, children, ClearAllChildren, Clone, clone, Destroy, destroy, FindFirstAncestor, FindFirstAncestorOfClass, FindFirstAncestorWhichIsA, FindFirstChild, findFirstChild, FindFirstChildOfClass, FindFirstChildWhichIsA, FindFirstDescendant, GetActor, GetAttribute, GetAttributeChangedSignal, GetAttributes, GetChildren, getChildren, GetDebugId, GetDescendants, GetFullName, GetStyled, GetStyledPropertyChangedSignal, GetTags, HasTag, IsAncestorOf, IsDescendantOf, isDescendantOf, IsPropertyModified, QueryDescendants, Remove, remove, RemoveTag, ResetPropertyToDefault, SetAttribute, WaitForChild