Skip to main content
Version: latest - a1.30.x ⚖️

👩‍💻 Player

Players are Entities that represents the individual behind the mouse and keyboard. Players are spawned automatically when connected to the server.

👪Inheritance
This class shares methods and events from Base Entity .
Authority

🟥 You cannot spawn or Destroy Players.

🎒 Examples

-- Spawns and possess a Character when a Player joins the server
Player.Subscribe("Spawn", function(player)
local new_char = Character()
player:Possess(new_char)
end)

-- Destroys the Character when the Player leaves the server
Player.Subscribe("Destroy", function(player)
local character = player:GetControlledCharacter()
if (character) then
character:Destroy()
end
end)

🗿 Static Functions

Inherited Entity Static Functions
Base Entityscripting-reference/classes/base-classes/entity
ReturnsNameDescription
table of Base Entity GetAllReturns a table containing all Entities of the class this is called on
Base Entity GetByIndexReturns a specific Entity of this class at an index
integer GetCountReturns how many Entities of this class exist
iterator GetPairsReturns an iterator with all Entities of this class to be used with pairs()
table InheritInherits this class with the Inheriting System
table of table GetInheritedClassesGets a list of all directly inherited classes from this Class created with the Inheriting System
table or nilGetParentClassGets the parent class if this Class was created with the Inheriting System
boolean IsChildOfGets if this Class is child of another class if this Class was created with the Inheriting System
function SubscribeSubscribes to an Event for all entities of this Class
function SubscribeRemoteSubscribes to a custom event called from server
UnsubscribeUnsubscribes all callbacks from this Event in this Class within this Package, or only the callback passed
This entity doesn't have own static functions.

🦠 Functions

Inherited Entity Functions
Base Entityscripting-reference/classes/base-classes/Entity
ReturnsNameDescription
integer GetIDGets the universal network ID of this Entity (same on both client and server)
table GetClassGets the class of this entity
boolean IsARecursively checks if this entity is inherited from a Class
function SubscribeSubscribes to an Event on this specific entity
function SubscribeRemoteSubscribes to a custom event called from server on this specific entity
UnsubscribeUnsubscribes all callbacks from this Event in this Entity within this Package, or only the callback passed
SetValueSets a Value in this Entity
any GetValueGets a Value stored on this Entity at the given key
DestroyDestroys this Entity
boolean IsValidReturns true if this Entity is valid (i.e. wasn't destroyed and points to a valid Entity)
CallRemoteEventCalls a custom remote event directly on this entity to a specific Player
CallRemoteEventCalls a custom remote event directly on this entity
BroadcastRemoteEventCalls a custom remote event directly on this entity to all Players
ReturnsNameDescription
BanBans the player from the server
ConnectRedirects the player to another server
KickKicks the player from the server
PossessMakes a Player to possess and control a Character
StartCameraFadeDoes a camera fade to/from a solid color
SetManualCameraFadeTurns on camera fading at the given opacity
StopCameraFadeStops camera fading.
SetCameraLocationSets the Player's Camera Location (only works if not possessing any Character)
SetCameraRotationSets the Player's Camera Rotation
TranslateCameraToSmoothly moves the Player's Camera Location (only works if not possessing any Character)
RotateCameraToSmoothly moves the Player's Camera Rotation
SetCameraSocketOffsetSets the Player's Camera Socket Offset (Spring Arm Offset)
SetCameraArmLengthSets the Player's Camera Arm Length (Spring Arm length)
AttachCameraToAttaches the Player`s Camera to an Actor
ResetCameraResets the Camera to default state (Unspectate and Detaches)
SpectateSpectates other Player
SetNameSets the player's name
SetVOIPChannelSets the VOIP Channel of this Player (will only communicate with other players in the same channel)
SetVOIPSettingSets the VOIP Settings of this Player
SetVOIPVolumeSets the VOIP Volume of this Player
UnPossessRelease the Player from the Character
string GetSteamID
string GetAccountID
string GetAccountName
Vector GetCameraLocation
Rotator GetCameraRotation
Character or nilGetControlledCharacter
string GetIP
integer GetDimensionGets this Player's dimension
string GetName
integer GetPing
integer GetVOIPChannel
any GetValue
boolean IsHost
boolean IsLocalPlayer
VOIPSettingGetVOIPSetting

Ban

Bans the player from the server
my_player:Ban(reason)
TypeParameterDefaultDescription
string reason

Connect

Redirects the player to another server
my_player:Connect(IP, password?)
TypeParameterDefaultDescription
string IP
string password?Server password

Kick

Kicks the player from the server
my_player:Kick(reason)
TypeParameterDefaultDescription
string reason

Possess

Makes a Player to possess and control a Character
my_player:Possess(new_character, blend_time?, exp?)
TypeParameterDefaultDescription
Character new_character
float blend_time?0
float exp?0

StartCameraFade

Does a camera fade to/from a solid color. Animates automatically
my_player:StartCameraFade(from_alpha, to_alpha, duration, to_color, should_fade_audio, hold_when_finished)
TypeParameterDefaultDescription
float from_alphaAlpha at which to begin the fade. Range [0..1], where 0 is fully transparent and 1 is fully opaque solid color.
float to_alphaAlpha at which to finish the fade.
float durationHow long the fade should take, in seconds.
Color to_colorColor to fade to/from.
boolean should_fade_audioTrue to fade audio volume along with the alpha of the solid color.
boolean hold_when_finishedTrue for fade to hold at the ToAlpha until explicitly stopped (e.g. with StopCameraFade)

SetManualCameraFade

Turns on camera fading at the given opacity. Does not auto-animate, allowing user to animate themselves. Call StopCameraFade to turn fading back off.
my_player:SetManualCameraFade(in_fade_amount, color, in_fade_audio)
TypeParameterDefaultDescription
float in_fade_amountRange [0..1], where 0 is fully transparent and 1 is fully opaque solid color.
Color color
boolean in_fade_audio

StopCameraFade

Stops camera fading.
my_player:StopCameraFade()

SetCameraLocation

Sets the Player's Camera Location (only works if not possessing any Character)
my_player:SetCameraLocation(location)
TypeParameterDefaultDescription
Vector location

SetCameraRotation

Sets the Player's Camera Rotation
my_player:SetCameraRotation(rotation)
TypeParameterDefaultDescription
Rotator rotation

TranslateCameraTo

Smoothly moves the Player's Camera Location (only works if not possessing any Character)
my_player:TranslateCameraTo(location, time, exp?)
TypeParameterDefaultDescription
Vector location
float time
float exp?0Exponential used to smooth interp, use 0 for linear movement

RotateCameraTo

Smoothly moves the Player's Camera Rotation
my_player:RotateCameraTo(rotation, time, exp?)
TypeParameterDefaultDescription
Rotator rotation
float time
float exp?0Exponential used to smooth interp, use 0 for linear movement

SetCameraSocketOffset

Sets the Player's Camera Socket Offset (Spring Arm Offset)
my_player:SetCameraSocketOffset(socket_offset)
TypeParameterDefaultDescription
Vector socket_offset

SetCameraArmLength

Sets the Player's Camera Arm Length (Spring Arm length)
my_player:SetCameraArmLength(length)
TypeParameterDefaultDescription
float length

AttachCameraTo

Attaches the Player`s Camera to an Actor
my_player:AttachCameraTo(actor, socket_offset, blend_speed)
TypeParameterDefaultDescription
Base Actor actor
Vector socket_offset
float blend_speed

ResetCamera

Resets the Camera to default state (Unspectate and Detaches)
my_player:ResetCamera()

Spectate

Spectates other Player
my_player:Spectate(player, blend_speed?)
TypeParameterDefaultDescription
Player player
float blend_speed?0

SetName

Sets the player's name
my_player:SetName(new_name)
TypeParameterDefaultDescription
string new_name

SetVOIPChannel

Sets the VOIP Channel of this Player (will only communicate with other players in the same channel)
my_player:SetVOIPChannel(channel)
TypeParameterDefaultDescription
integer channel

SetVOIPSetting

Sets the VOIP Settings of this Player
my_player:SetVOIPSetting(setting)
TypeParameterDefaultDescription
VOIPSettingsetting

SetVOIPVolume

Sets the VOIP Volume of this Player
my_player:SetVOIPVolume(volume)
TypeParameterDefaultDescription
float volume

UnPossess

Release the Player from the Character
my_player:UnPossess()

GetSteamID



Returns string
local ret = my_player:GetSteamID()

GetAccountID



Returns string
local ret = my_player:GetAccountID()

GetAccountName



Returns string
local ret = my_player:GetAccountName()

GetCameraLocation



Returns Vector
local ret = my_player:GetCameraLocation()

GetCameraRotation



Returns Rotator
local ret = my_player:GetCameraRotation()

GetControlledCharacter



Returns Character or nil
local ret = my_player:GetControlledCharacter()

GetIP



Returns string
local ret = my_player:GetIP()

GetDimension

Gets this Player's dimension

Returns integer
local ret = my_player:GetDimension()

GetName



Returns string
local ret = my_player:GetName()

GetPing



Returns integer
local ret = my_player:GetPing()

GetVOIPChannel



Returns integer
local ret = my_player:GetVOIPChannel()

GetValue



Returns any
local ret = my_player:GetValue(key, fallback)
TypeParameterDefaultDescription
string key
any fallback

IsHost



Returns boolean
local ret = my_player:IsHost()

IsLocalPlayer



Returns boolean
local ret = my_player:IsLocalPlayer()

GetVOIPSetting



Returns VOIPSetting
local ret = my_player:GetVOIPSetting()

🚀 Events

Inherited Entity Events
Base Entityscripting-reference/classes/base-classes/Entity
NameDescription
SpawnTriggered when an Entity is spawned/created
DestroyTriggered when an Entity is destroyed
ValueChangeTriggered when an Entity has a value changed with :SetValue()
ClassRegisterTriggered when a new Class is registered with the Inheriting System
NameDescription
DimensionChangeTriggered when a Player changes it's dimension
PossessTrigerred when Player starts controlling a Character
ReadyTriggered when Player is ready (the client fully joined, loaded the map and all entities and is ready to play)
UnPossessA Character was released from the Player
VOIPWhen a Player starts/ends using VOIP

DimensionChange

Triggered when a Player changes it's dimension
Player.Subscribe("DimensionChange", function(self, old_dimension, new_dimension)

end)
TypeArgumentDescription
Player self
integer old_dimension
integer new_dimension

Possess

Trigerred when Player starts controlling a Character
Player.Subscribe("Possess", function(self, character)

end)
TypeArgumentDescription
Player self
Character character

Ready

Triggered when Player is ready (the client fully joined, loaded the map and all entities and is ready to play)
Player.Subscribe("Ready", function(self)

end)
TypeArgumentDescription
Player self

UnPossess

A Character was released from the Player
Player.Subscribe("UnPossess", function(self, character)

end)
TypeArgumentDescription
Player self
Character character

VOIP

When a Player starts/ends using VOIP
Player.Subscribe("VOIP", function(self, is_talking)

end)
TypeArgumentDescription
Player self
boolean is_talking