đ©âđ» Player
đ„ Authority: You cannot spawn or Destroy Players.
Players are Entities that represents the individual behind the mouse and keyboard. Players are spawned automatically when connected to the server.
Usageâ
-- 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)
Functionsâ
Returns | Name | Description | |
---|---|---|---|
Ban | Bans the player from the server | ||
Connect | Redirects the player to another server | ||
Kick | Kicks the player from the server | ||
Possess | Bind the Player to a Character | ||
![]() | SetCameraLocation | Sets the Playerâs Camera Location | |
![]() | SetCameraRotation | Sets the Playerâs Camera Rotation | |
![]() | SetCameraSocketOffset | Sets the Playerâs Camera Socket Offset | |
![]() | SetCameraArmLength | Sets the Playerâs Camera Arm Length | |
![]() | AttachCameraTo | Attaches the Playerâs Camera to an Actor | |
![]() | ResetCamera | Resets the Playerâs Camera to the default state | |
![]() | Spectate | Spectates another Player | |
SetName | Sets the playerâs name | ||
![]() | Definir Valor | Sets a value in this entity, which can be accessed by any package | |
SetVOIPChannel | Sets the VOIP Channel of this Player | ||
![]() | SetVOIPSetting | Sets the VOIP Settings of this Player | |
![]() | SetVOIPVolume | Sets the VOIP Volume of this Player | |
UnPossess | Release the Player from the Character | ||
![]() | string | GetSteamID | Gets the Steam account ID |
![]() | string | GetAccountID | Gets the nanos account ID |
![]() | string | GetAccountName | Gets the nanos account name |
Vector | GetCameraLocation | Gets the Playerâs Camera Location | |
Rotator | GetCameraRotation | Gets the Playerâs Camera Rotation | |
![]() | Character | GetControlledCharacter | Returns the character of the player |
![]() | number | GetID | Gets the network ID of this entity |
string | GetIP | Gets the IP of this Player | |
![]() | string | GetName | Returns the playerâs name |
![]() | number | GetPing | Returns the ping of a player |
![]() | string | GetType | Returns the type of this Actor |
![]() | number | GetVOIPChannel | Returns the VOIP Channel of this Player |
![]() | any | valorDeGetValue | Gets a value given a key |
boolean | IsHost | Returns if this Player started the server from New Game | |
boolean | IsLocalPlayer | Returns if this is the LocalPlayer | |
![]() | boolean | IsValid | Returns if this entity is valid (i.e. wasnât destroyed and points to a valid entity) |
![]() | VOIPSetting | GetVOIPSetting | Returns this Player VOIP Setting |
![]() | function | Subscribe | Subscribes for an Event |
![]() | Unsubscribe | Unsubscribes from all subscribed Events in this Entity and in this Package |
Eventsâ
Name | Description | |
---|---|---|
Destroy | Triggered when Player disconnects from the server | |
Possess | A Player was bound to a Character | |
Spawn | Triggered when Player connects to the server | |
Ready | Triggered when Player is ready (the client fully joined, loaded the map and all entities and is ready to play) | |
UnPossess | A Character was released from the Player | |
VOIP | When a Player starts/ends using VOIP |
Functions Detailedâ

Ban
â
Bans the player from the server
my_player:Ban(reason)
Type | Parameter | Description |
---|---|---|
string | reason |

Connect
â
Redirects the player to another server
my_player:Connect(IP, password = "")
Type | Parameter | Default Value | Description |
---|---|---|---|
string | IP | IP do Servidor | |
string | Senha | "" | Senha do servidor |

Kick
â
Kicks the player from the server
my_player:Kick(reason)
Type | Parameter | Description |
---|---|---|
string | reason |

Possess
â
Makes a
Player
to possess and control aCharacter
my_player:Possess(new_character, blend_time, exp)
Type | Parameter | Description |
---|---|---|
Character | new_character | |
number | blend_time | 0 |
number | exp | 0 |

SetCameraLocation
â
Sets the Player's Camera Location (only works if not possessing any Character)
my_player:SetCameraLocation(location)
Type | Parameter | Default | Description |
---|---|---|---|
Vector | location |

SetCameraRotation
â
Sets the Player's Camera Rotation
my_player:SetCameraRotation(rotation)
Type | Parameter | Default | Description |
---|---|---|---|
Rotator | rotation |

TranslateCameraTo
â
Smoothly moves the Player's Camera Location (only works if not possessing any Character)
my_player:TranslateCameraTo(location, time, exp)
Type | Parameter | Default | Description |
---|---|---|---|
Vector | location | ||
number | time | Time to interp from current camera location to target location | |
number | exp | 0 | Exponential used to smooth interp, use 0 for linear movement |

RotateCameraTo
â
Smoothly moves the Player's Camera Rotation
my_player:RotateCameraTo(rotation, time, exp)
Type | Parameter | Default | Description |
---|---|---|---|
Rotator | rotation | ||
number | time | Time to interp from current camera rotation to target rotation | |
number | exp | 0 | Exponential 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)
Type | Parameter | Default | Description |
---|---|---|---|
Vector | socket_offset |

SetCameraArmLength
â
Sets the Playerâs Camera Arm Length (Spring Arm length)
my_player:SetCameraArmLength(length)
Type | Parameter | Default | Description |
---|---|---|---|
number | length |

AttachCameraTo
â
Attaches the Player`s Camera to an Actor
my_player:AttachCameraTo(actor, socket_offset, blend_speed)
Type | Parameter | Default | Description |
---|---|---|---|
Base Actor | actor | ||
Vector | socket_offset | ||
number | 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)
Type | Parameter | Default | Description |
---|---|---|---|
Player | player | ||
number | blend_speed |

SetName
â
Sets the player's name
my_player:SetName(new_name)
Type | Parameter | Description |
---|---|---|
string | new_name |

SetValue
â
Sets a value in this entity, which can be accessed by any package (optionally sync on clients if called from server)
Please refer to Entity Values for more information
my_player:SetValue(key, value, sync_on_clients)
Type | Parameter | Default Value | Description |
---|---|---|---|
string | key | Key | |
any | value | Value | |
boolean | sync_on_clients | false | Server side parameter, if enabled will sync this value through all clients |

SetVOIPChannel
â
Sets the VOIP Channel of this Player (will only communicate with other players in the same channel)
my_player:SetVOIPChannel(channel)
Type | Parameter | Description |
---|---|---|
number | channel |

SetVOIPSetting
â
Sets the VOIP Settings of this Player
my_player:SetVOIPSetting(setting)
Type | Parameter | Description |
---|---|---|
VOIPSetting | setting |

SetVOIPVolume
â
Sets the VOIP Volume of this Player
my_player:SetVOIPSetting(volume)
Type | Parameter | Description |
---|---|---|
number | volume |

UnPossess
â
Release the
Player
from the :ref:Character
my_player:UnPossess()

GetSteamID
â
Gets the Steam account ID
Returns string
my_player:GetSteamID()

GetAccountID
â
Gets the nanos account ID
Returns string
my_player:GetAccountID()

GetAccountName
â
Gets the nanos account name
Returns string
my_player:GetAccountName()

GetCameraLocation
â
Gets the Player's Camera Location
Returns Vector
my_player:GetCameraLocation()

GetCameraRotation
â
Gets the Player's Camera Rotation
Returns Rotator
my_player:GetCameraRotation()

GetControlledCharacter
â
Returns the character of the player. If the player has not yet been assigned a character, nil is returned
Returns Character or nil
my_player:GetControlledCharacter()

GetID
â
Gets the network ID of this entity (same in both client and server)
Returns number
my_player:GetID()

GetIP
â
Gets the IP of this Player
Returns string
my_player:GetIP()

GetName
â
Returns the player's name
Returns string
my_player:GetName()

GetPing
â
Returns the ping of a player
Returns number
my_player:GetPing()

GetType
â
Returns the type of this Actor
Returns string
my_player:GetType()

GetVOIPChannel
â
Returns the VOIP Channel of this Player
Returns VOIPChannel
my_player:GetVOIPChannel()

GetValue
â
Gets a value given a key. Please refer to Entity Values for more information
Returns any
my_player:GetValue(key, fallback)
Type | Parameter | Default Value | Description |
---|---|---|---|
string | key | Key | |
any | fallback | Fallback Value if key doesn't exist |

IsHost
â
Returns if this Player started the server from New Game menu
Returns boolean
my_player:IsHost()

IsLocalPlayer
â
Returns if this is the LocalPlayer
Returns boolean
my_player:IsLocalPlayer()

IsValid
â
Returns if this entity is valid (i.e. wasn't destroyed and points to a valid entity)
Returns boolean
my_player:IsValid()

GetVOIPSetting
â
Returns this Player VOIP Setting
Returns VOIPSetting
my_player:GetVOIPSetting()

Subscribe
â
Subscribes for an Event
Returns the function callback itself
my_player:Subscribe(event_name, callback)
Type | Parameter | Default Value | Description |
---|---|---|---|
string | event_name | ||
function | function |

Unsubscribe
â
Unsubscribes from all subscribed Events in this Entity and in this Package, optionally passing the function to unsubscribe only that callback
my_player:Unsubscribe(event_name, callback)
Type | Parameter | Default Value | Description |
---|---|---|---|
string | event_name | ||
function | function | nil |
Events Detailedâ
Destroy
â
Triggered when Player disconnects from the server
Player.Subscribe("Destroy", function(self)
end)
Type | Parameter | Description |
---|---|---|
Player | self |
Possess
â
A Player is now controlling a Character
Player.Subscribe("Possess", function(self, character)
end)
Type | Parameter | Description |
---|---|---|
Player | self | |
Character | character |
Spawn
â
Triggered when Player connects to the server
Player.Subscribe("Spawn", function(self)
end)
Type | Parameter | Description |
---|---|---|
Player | self |

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)
Type | Parameter | Description |
---|---|---|
Player | self |
UnPossess
â
A Character was released from the
Player
Player.Subscribe("UnPossess", function(self, character)
end)
Type | Parameter | Description |
---|---|---|
Player | self | |
Character | character |
VOIP
â
When a Player starts/ends using VOIP
Player.Subscribe("VOIP", function(self, is_talking)
end)
Type | Parameter | Description |
---|---|---|
Player | self | |
boolean | is_talking |