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

StarterPlayer

Show deprecated

StarterPlayer

Show deprecated

A service which allows the defaults of properties in the Player object to be set. When a player enters the server, each property of the player object is set to the current value of the corresponding property in StarterPlayer.

Additionally, you may add four objects to this service:

  • A StarterPlayerScripts instance, with scripts that run once for each player.
  • A StarterCharacterScripts instance, with scripts to add to each player’s character every time they spawn.
  • A Humanoid instance named StarterHumanoid, which will be used as the default humanoid for each player’s character.
  • A Model instance named StarterCharacter, which will be used as the character model for all players

A typical structure may look something like this:
StarterPlayer Tree

Properties

bool

AllowCustomAnimations

[Hidden]

Describes the current game’s permission levels regarding custom avatar animations from the website

bool

AutoJumpEnabled

Sets whether the character will automatically jump when hitting an obstacle on a mobile device.

float

CameraMaxZoomDistance

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

float

CameraMinZoomDistance

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

CameraMode

CameraMode

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

float

CharacterJumpHeight

float

CharacterJumpPower

float

CharacterMaxSlopeAngle

bool

CharacterUseJumpPower

float

CharacterWalkSpeed

DevCameraOcclusionMode

DevCameraOcclusionMode

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

DevComputerCameraMovementMode

DevComputerCameraMovementMode

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

DevComputerMovementMode

DevComputerMovementMode

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

DevTouchCameraMovementMode

DevTouchCameraMovementMode

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

DevTouchMovementMode

DevTouchMovementMode

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

bool

EnableMouseLockOption

Determines if a player can toggle mouse lock by default.

float

HealthDisplayDistance

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

bool

LoadCharacterAppearance

Whether or not the appearance of a player’s character should be loaded.

float

NameDisplayDistance

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

bool

UserEmotesEnabled

Inherited from Instance: Show Hide

bool

Archivable

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

string

ClassName

[ReadOnly] [NotReplicated]

A read-only string representing the class this Instance belongs to

int

DataCost

[ReadOnly] [NotReplicated] [Deprecated]

The cost of saving the instance using data persistence.

string

Name

A non-unique identifier of the Instance

Instance

Parent

Determines the hierarchical parent of the Instance

bool

RobloxLocked

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

bool

archivable

[Hidden] [NotReplicated] [Deprecated]
string

className

[ReadOnly] [NotReplicated] [Deprecated]

Functions

Inherited from Instance: Show Hide

void

ClearAllChildren ( )

This function destroys all of an Instance's children.

Instance

Clone ( )

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

void

Destroy ( )

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

Instance

FindFirstAncestor ( string name )

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

Instance

FindFirstAncestorOfClass ( string className )

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

Instance

FindFirstAncestorWhichIsA ( string className )

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

Instance

FindFirstChild ( string name , bool recursive )

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

Instance

FindFirstChildOfClass ( string className )

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

Instance

FindFirstChildWhichIsA ( string className , bool recursive )

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

Variant

GetAttribute ( string attribute )

RBXScriptSignal

GetAttributeChangedSignal ( string attribute )

Dictionary

GetAttributes ( )

Objects

GetChildren ( )

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

string

GetDebugId ( int scopeLength )

[NotBrowsable]

Returns a coded string of the Instances DebugId used internally by Roblox.

Array

GetDescendants ( )

[CustomLuaState]

Returns an array containing all of the descendants of the instance

string

GetFullName ( )

Returns a string describing the Instance's ancestry.

RBXScriptSignal

GetPropertyChangedSignal ( string property )

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

bool

IsA ( string className )

[CustomLuaState]

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

bool

IsAncestorOf ( Instance descendant )

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

bool

IsDescendantOf ( Instance ancestor )

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

void

Remove ( )

[Deprecated]

Sets the object’s Parent to nil, and does the same for all its descendants.

void

SetAttribute ( string attribute , Variant value )

Instance

WaitForChild ( string childName , double timeOut )

[CustomLuaState] [CanYield]

Returns the child of the Instance with the given name. If the child does not exist, it will yield the current thread until it does.

Objects

children ( )

[Deprecated]

Returns an array of the object’s children.

Instance

clone ( )

[Deprecated]
void

destroy ( )

[Deprecated]
Instance

findFirstChild ( string name , bool recursive )

[Deprecated]
Objects

getChildren ( )

[Deprecated]
bool

isA ( string className )

[Deprecated] [CustomLuaState]
bool

isDescendantOf ( Instance ancestor )

[Deprecated]
void

remove ( )

[Deprecated]

Events

Inherited from Instance: Show Hide

RBXScriptSignal

AncestryChanged ( Instance child , Instance parent )

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

RBXScriptSignal

AttributeChanged ( string attribute )

RBXScriptSignal

Changed ( string property )

Fired immediately after a property of an object changes.

RBXScriptSignal

ChildAdded ( Instance child )

Fires when an object is parented to this Instance.

RBXScriptSignal

ChildRemoved ( Instance child )

Fires when a child is removed from this Instance.

RBXScriptSignal

DescendantAdded ( Instance descendant )

Fires when a descendant is added to the Instance

RBXScriptSignal

DescendantRemoving ( Instance descendant )

Fires immediately before a descendant of the Instance is removed.

RBXScriptSignal

childAdded ( Instance child )

[Deprecated]

Code Samples


Setting Camera Zoom Distance

​The example demonstrates how to set a player’s camera minimum and maximum zoom distance.

In this example, we set the Player/CameraMinZoomDistance and Player/CameraMaxZoomDistance to set the min and max distance in studs a player’s camera can be from their character.

Note that since the example attempts to set the CameraMinZoomDistance to be greater than the CameraMaxZoomDistance, the CameraMinZoomDistance value will be decreased and set to the value of the max zoom distance.

To change the default min and max zoom distance values for a player when they first enter the game, you can change the StarterPlayer/CameraMinZoomDistance and StarterPlayer/CameraMaxZoomDistance properties.

local player = game.Players.LocalPlayer

player.CameraMaxZoomDistance = 50
player.CameraMinZoomDistance = 75

Displaying a Humanoid's Health and Name

This example demonstrates how to set a Humanoid's Humanoid/DisplayerDistanceType, Humanoid/HealthDisplayDistance, and Humanoid/NameDisplayDistance properties. These properties determine how a humanoid’s healthbar and name are rendered for a player.

First, we change the DisplayDistanceType to Viewer using Enum/HumanoidDisplayDistanceType. When set to viewer, the humanoid’s Name and healthbar will be displayed based on the distance settings of the humanoid viewing them.

Then, the humanoid’s HealthDisplayDistance is set to 0. Setting the property to 0 hides the healthbar completely. It is not displayed at any distance.

Finally, the humanoid’s NameDisplayDistance is set to 100. This means that the humanoid’s name will be visible to other humanoid’s within 100 studs.

This example should work as expected when placed inside a Script that is a child of the humanoid.

local humanoid = script.Parent

humanoid.DisplayDistanceType = Enum.HumanoidDisplayDistanceType.Viewer
humanoid.HealthDisplayDistance = 0
humanoid.NameDisplayDistance = 100

Setting a Player's Replication Focus

This example creates a new BasePart and sets the Player's Player/ReplicationFocus to that part.

This demonstrates the functionality of the ReplicationFocus property. You can easily change the part that the focus is set to to change the replication focus.

local part = Instance.new("Part")
part.Parent = game.Workspace
part.Name = "ReplicationFocusPart"
part.Anchored = true

local player = game.Players.LocalPlayer
player.ReplicationFocus = part