Skip to main content
Version: latest - a1.15.x βš–οΈ

πŸ‘©β€πŸ’» Player

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

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)

🦠 Functions​

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
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
SetValueSets 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
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
number GetID
string GetIP
string GetName
number GetPing
string GetType
number GetVOIPChannel
any GetValue
boolean IsHost
boolean IsLocalPlayer
boolean IsValid
VOIPSettingGetVOIPSetting
function Subscribe
UnsubscribeUnsubscribes from all subscribed Events in this Entity and in this Package, optionally passing the function to unsubscribe only that callback

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
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)
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
number time
number 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
number time
number 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
number 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
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?)
TypeParameterDefaultDescription
Player player
number blend_speed?0

SetName​

Sets the player's name
my_player:SetName(new_name)
TypeParameterDefaultDescription
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?)
TypeParameterDefaultDescription
string key
any value
boolean sync_on_clients?falseServer 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)
TypeParameterDefaultDescription
number 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
number 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()

GetID​



Returns number ()
local ret = my_player:GetID()

GetIP​



Returns string ()
local ret = my_player:GetIP()

GetName​



Returns string ()
local ret = my_player:GetName()

GetPing​



Returns number ()
local ret = my_player:GetPing()

GetType​



Returns string ()
local ret = my_player:GetType()

GetVOIPChannel​



Returns number ()
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()

IsValid​



Returns boolean ()
local ret = my_player:IsValid()

GetVOIPSetting​



Returns VOIPSetting ()
local ret = my_player:GetVOIPSetting()

Subscribe​



Returns function ()
local ret = my_player:Subscribe(event_name, function)
TypeParameterDefaultDescription
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, function)
TypeParameterDefaultDescription
string event_name
function function

πŸš€ Events​

NameDescription
DestroyTriggered when Player disconnects from the server
PossessTrigerred when Player starts controlling a Character
SpawnTriggered when Player connects to the server
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

Destroy​

Triggered when Player disconnects from the server
Player.Subscribe("Destroy", function(self)

end)
TypeArgumentDescription
Player self

Possess​

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

end)
TypeArgumentDescription
Player self
Character character

Spawn​

Triggered when Player connects to the server
Player.Subscribe("Spawn", function(self)

end)
TypeArgumentDescription
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)
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