Skip to main content

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(Vector(), Rotator(), "helix::SK_Male")
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 EntityGetAllReturns a table containing all Entities of the class this is called on
Base EntityGetByIndexReturns a specific Entity of this class at an index
integerGetCountReturns how many Entities of this class exist
iteratorGetPairsReturns an iterator with all Entities of this class to be used with pairs()
tableInheritInherits this class with the Inheriting System
table of tableGetInheritedClassesGets 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
booleanIsChildOfGets if this Class is child of another class if this Class was created with the Inheriting System
functionSubscribeSubscribes to an Event for all entities of this Class
functionSubscribeRemoteSubscribes 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
integerGetIDGets the universal network ID of this Entity (same on both client and server)
tableGetClassGets the class of this entity
booleanIsARecursively checks if this entity is inherited from a Class
functionSubscribeSubscribes to an Event on this specific entity
functionSubscribeRemoteSubscribes 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
anyGetValueGets a Value stored on this Entity at the given key
DestroyDestroys this Entity
booleanIsValidReturns 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
stringGetAccountID
stringGetAccountName
stringGetAccountIconURLReturn a URL which can be used through WebUI and Widgets to display the Player's Steam Avatar (64x64)
VectorGetCameraLocation
floatGetCameraArmLength
RotatorGetCameraRotation
Character or nilGetControlledCharacter
stringGetIP
integerGetDimensionGets this Player's dimension
stringGetName
integerGetPing
integerGetVOIPChannel
anyGetValue
booleanIsHost
booleanIsLocalPlayer
VOIPSettingGetVOIPSetting

Ban

Bans the player from the server

my_player:Ban(reason)
TypeParameterDefaultDescription
stringreason

Connect

Redirects the player to another server

my_player:Connect(IP, password?)
TypeParameterDefaultDescription
stringIP
stringpassword?Server password

Kick

Kicks the player from the server

my_player:Kick(reason)
TypeParameterDefaultDescription
stringreason

Possess

Makes a Player to possess and control a Character

my_player:Possess(new_character, blend_time?, exp?)
TypeParameterDefaultDescription
Characternew_character
floatblend_time?0
floatexp?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
floatfrom_alphaAlpha at which to begin the fade. Range [0..1], where 0 is fully transparent and 1 is fully opaque solid color.
floatto_alphaAlpha at which to finish the fade.
floatdurationHow long the fade should take, in seconds.
Colorto_colorColor to fade to/from.
booleanshould_fade_audioTrue to fade audio volume along with the alpha of the solid color.
booleanhold_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
floatin_fade_amountRange [0..1], where 0 is fully transparent and 1 is fully opaque solid color.
Colorcolor
booleanin_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
Vectorlocation

SetCameraRotation

Sets the Player's Camera Rotation

my_player:SetCameraRotation(rotation)
TypeParameterDefaultDescription
Rotatorrotation

TranslateCameraTo

Smoothly moves the Player's Camera Location (only works if not possessing any Character)

my_player:TranslateCameraTo(location, time, exp?)
TypeParameterDefaultDescription
Vectorlocation
floattime
floatexp?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
Rotatorrotation
floattime
floatexp?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
Vectorsocket_offset

SetCameraArmLength

Sets the Player's Camera Arm Length (Spring Arm length)

my_player:SetCameraArmLength(length, force)
TypeParameterDefaultDescription
floatlength
booleanforceWhether to bypass interpolation and set the target to its value directly

AttachCameraTo

Attaches the Player`s Camera to an Actor

my_player:AttachCameraTo(actor, socket_offset, blend_speed)
TypeParameterDefaultDescription
Base Actoractor
Vectorsocket_offset
floatblend_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
Playerplayer
floatblend_speed?0

SetName

Sets the player's name

my_player:SetName(new_name)
TypeParameterDefaultDescription
stringnew_name

SetVOIPChannel

Sets the VOIP Channel of this Player (will only communicate with other players in the same channel)

my_player:SetVOIPChannel(channel)
TypeParameterDefaultDescription
integerchannel

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
floatvolume

UnPossess

Release the Player from the Character

my_player:UnPossess()

GetAccountID

— Returns string.

local ret = my_player:GetAccountID()

GetAccountName

— Returns string.

local ret = my_player:GetAccountName()

GetAccountIconURL

Return a URL which can be used through WebUI and Widgets to display the Player's Steam Avatar (64x64)

— Returns string.

local ret = my_player:GetAccountIconURL()

GetCameraLocation

— Returns Vector.

local ret = my_player:GetCameraLocation()

GetCameraArmLength

— Returns float.

local ret = my_player:GetCameraArmLength(return_base?)
TypeParameterDefaultDescription
booleanreturn_base?falseWhether to return the current (false) or base (true) value. The base is the same value set by SetCameraArmLength().

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
stringkey
anyfallback

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)
-- DimensionChange was called
end)
TypeArgumentDescription
Playerself
integerold_dimension
integernew_dimension

Possess

Trigerred when Player starts controlling a Character
Player.Subscribe("Possess", function(self, character)
-- Possess was called
end)
TypeArgumentDescription
Playerself
Charactercharacter

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)
-- Ready was called
end)
TypeArgumentDescription
Playerself

UnPossess

A Character was released from the Player
Player.Subscribe("UnPossess", function(self, character)
-- UnPossess was called
end)
TypeArgumentDescription
Playerself
Charactercharacter

VOIP

When a Player starts/ends using VOIP

When 'is_talking' is true, return false to prevent this voice stream from playing (on server will prevent for everyone, on client will prevent only for the client)
Player.Subscribe("VOIP", function(self, is_talking)
-- VOIP was called
end)
TypeArgumentDescription
Playerself
booleanis_talking