Skip to main content
Version: bleeding-edge 🩸

👩‍💻 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.
🧑‍💻API Source
This page is auto-generated! The Functions, Properties and Events described here are defined in our GitHub's API Repository! Feel free to commit suggestions and changes to the source .json API files!

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(), "nanos-world::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
Player inherits from Base Entity Class, sharing it's methods and 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
table of tableGetInheritedClassesGets a list of all directly inherited classes from this Class created with the Inheriting System
iteratorGetPairsReturns an iterator with all Entities of this class to be used with pairs()
table or nilGetParentClassGets the parent class if this Class was created with the Inheriting System
tableInheritInherits this class 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
ReturnsNameDescription
Player or nilGetBySteamIDRetrieves a player by their Steam ID

GetBySteamID

Retrieves a player by their Steam ID
local player = Player.GetBySteamID(steam_id)

Parameters

TypeParameterDefaultDescription
stringsteam_id Required parameter No description provided

Returns

TypeDescription
Player or nilplayer

🦠 Functions

Inherited Entity Functions
Player inherits from Base Entity Class, sharing it's methods and functions:
Base Entityscripting-reference/classes/base-classes/entity
ReturnsNameDescription
BroadcastRemoteEventCalls a custom remote event directly on this entity to all Players
BroadcastRemoteInRadiusEventCalls a custom remote event directly on this entity to all Players in a radius
CallRemoteEventCalls a custom remote event directly on this entity to a specific Player
CallRemoteEventCalls a custom remote event directly on this entity
CallRemotePlayersEventCalls a custom remote event directly on this entity to a list of Players
DestroyDestroys this Entity
FinishSpawnFinish the spawning process and send the entity to clients if it was spawned with defer_spawn
table of stringGetAllValuesKeysGets a list of all values keys
tableGetClassGets the class of this entity
integerGetIDGets the universal network ID of this Entity (same on both client and server)
anyGetValueGets a Value stored on this Entity at the given key
booleanHasAuthorityGets if the local context has authority over this Entity (true if spawned by the client, false if spawned by the server)
booleanIsARecursively checks if this entity is inherited from a Class
booleanIsBeingDestroyedReturns true if this Entity is being destroyed
booleanIsValidReturns true if this Entity is valid (i.e. wasn't destroyed and points to a valid Entity)
SetValueSets a Value in this Entity
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
ReturnsNameDescription
AttachCameraToAttaches the Player`s Camera to an Actor
BanBans the player from the server
ConnectRedirects the player to another server
stringGetAccountIconURLReturn a URL which can be used through WebUI and Widgets to display the Player's Steam Avatar (64x64)
stringGetAccountIDNo description provided
stringGetAccountNameNo description provided
floatGetCameraArmLengthNo description provided
VectorGetCameraLocationNo description provided
RotatorGetCameraRotationNo description provided
Base Pawn or nilGetControlledCharacterNo description provided
integerGetDimensionGets this Player's dimension
stringGetIPNo description provided
stringGetNameNo description provided
integerGetPingNo description provided
stringGetSteamIDNo description provided
table of integerGetVOIPListeningChannelsReturns a list of VOIP channels this player is listening to
table of integerGetVOIPSpeakingChannelsReturns a list of VOIP channels this player is currently speaking to
booleanIsHostNo description provided
booleanIsLocalPlayerNo description provided
booleanIsVOIPMutedReturns whether VOIP is muted for this player
KickKicks the player from the server
PossessMakes a Player to possess and control a Pawn (Character)
ResetCameraResets the Camera to default state (Unspectate and Detaches)
RotateCameraToSmoothly moves the Player's Camera Rotation
SetCameraArmLengthSets the Player's Camera Arm Length (Spring Arm length)
SetCameraFOVSets the Player's Camera FOV (if not possessing a Character)
SetCameraLocationSets the Player's Camera Location (only works if not possessing any Character)
SetCameraRotationSets the Player's Camera Rotation
SetCameraSocketOffsetSets the Player's Camera Socket Offset (Spring Arm Offset)
SetCameraSpeedSettingsSets the Player's Camera Speed Settings (if not possessing a Character)
SetDimensionSets this Player's dimension
SetDistanceOptimizationMultiplierSets this Player's distance optimization multiplier
SetManualCameraFadeTurns on camera fading at the given opacity
SetNameSets the player's name
SetVOIPGlobalAllChannelsSettingSets the VOIP setting for all global channels
SetVOIPGlobalChannelSettingSets the VOIP setting for a specific global channel
SetVOIPGlobalHighPassFilterSets the global VOIP high-pass filter threshold frequency
SetVOIPGlobalLowPassFilterSets the global VOIP low-pass filter threshold frequency
SetVOIPGlobalVolumeSets the global VOIP volume. It only affects the global channels
SetVOIPLocalMaxDistanceSets the local/proximity VOIP max distance. This also affects networking usage
SetVOIPLocalSettingSets the VOIP setting for the local/proximity
SetVOIPLocalVolumeSets the local/proximity VOIP input/output volume. It only affects the local/proximity channel
SetVOIPMutedMutes or unmutes VOIP for this player
SpectateSpectates other Player
StartCameraFadeDoes a camera fade to/from a solid color
StopCameraFadeStops camera fading.
TranslateCameraToSmoothly moves the Player's Camera Location (only works if not possessing any Character)
UnPossessRelease the Player from the Character

AttachCameraTo

Attaches the Player`s Camera to an Actor
my_player:AttachCameraTo(actor, socket_offset?, blend_speed?)

Parameters

TypeParameterDefaultDescription
Base Actoractor Required parameter No description provided
Vectorsocket_offset?Vector(0, 0, 0)No description provided
floatblend_speed?0.0No description provided

Ban

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

Parameters

TypeParameterDefaultDescription
stringreason Required parameter No description provided

Connect

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

Parameters

TypeParameterDefaultDescription
stringIP Required parameter No description provided
stringpassword?Server password

GetAccountIconURL

Return a URL which can be used through WebUI and Widgets to display the Player's Steam Avatar (64x64)
local account_icon_url = my_player:GetAccountIconURL()

Returns

TypeDescription
stringaccount_icon_url

GetAccountID

local account_id = my_player:GetAccountID()

Returns

TypeDescription
stringaccount_id

GetAccountName

local account_name = my_player:GetAccountName()

Returns

TypeDescription
stringaccount_name

GetCameraArmLength

local length = my_player:GetCameraArmLength(return_base?)

Parameters

TypeParameterDefaultDescription
booleanreturn_base?falseWhether to return the current (false) or base (true) value. The base is the same value set by SetCameraArmLength(). Use base if you want to get the original value set by SetCameraArmLength() and not the current (interpolated) value.

Returns

TypeDescription
floatlength

See also SetCameraArmLength.


GetCameraLocation

local location = my_player:GetCameraLocation()

Returns

TypeDescription
Vectorlocation

See also SetCameraLocation.


GetCameraRotation

local rotation = my_player:GetCameraRotation()

Returns

TypeDescription
Rotatorrotation

See also SetCameraRotation.


GetControlledCharacter

local controlled_character = my_player:GetControlledCharacter()

Returns

TypeDescription
Base Pawn or nilcontrolled_character

GetDimension

Gets this Player's dimension
local dimension = my_player:GetDimension()

Returns

TypeDescription
integerdimension

See also SetDimension, DimensionChange.


GetIP

local ip = my_player:GetIP()

Returns

TypeDescription
stringip

GetName

local player_name = my_player:GetName()

Returns

TypeDescription
stringplayer_name

See also SetName.


GetPing

local ping = my_player:GetPing()

Returns

TypeDescription
integerping

GetSteamID

local steam_id = my_player:GetSteamID()

Returns

TypeDescription
stringsteam_id

GetVOIPListeningChannels

Returns a list of VOIP channels this player is listening to
local ret = my_player:GetVOIPListeningChannels()

Returns

TypeDescription
table of integerlist of channel indexes

GetVOIPSpeakingChannels

Returns a list of VOIP channels this player is currently speaking to
local ret = my_player:GetVOIPSpeakingChannels()

Returns

TypeDescription
table of integerlist of channel indexes

IsHost

local is_host = my_player:IsHost()

Returns

TypeDescription
booleanis_host

IsLocalPlayer

local is_local_player = my_player:IsLocalPlayer()

Returns

TypeDescription
booleanis_local_player

IsVOIPMuted

Returns whether VOIP is muted for this player
local ret = my_player:IsVOIPMuted()

Returns

TypeDescription
booleanNo description provided

See also SetVOIPMuted.


Kick

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

Parameters

TypeParameterDefaultDescription
stringreason Required parameter No description provided

Possess

Makes a Player to possess and control a Pawn (Character)
my_player:Possess(new_pawn, blend_time?, exp?)

Parameters

TypeParameterDefaultDescription
Base Pawnnew_pawn Required parameter No description provided
floatblend_time?0No description provided
floatexp?0No description provided

ResetCamera

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

RotateCameraTo

Smoothly moves the Player's Camera Rotation
my_player:RotateCameraTo(rotation, time, exp?)

Parameters

TypeParameterDefaultDescription
Rotatorrotation Required parameter No description provided
floattime Required parameter No description provided
floatexp?0Exponential used to smooth interp, use 0 for linear movement

SetCameraArmLength

Sets the Player's Camera Arm Length (Spring Arm length)
my_player:SetCameraArmLength(length, force?)

Parameters

TypeParameterDefaultDescription
floatlength Required parameter No description provided
booleanforce?falseWhether to bypass interpolation and set the target to its value directly

See also GetCameraArmLength.


SetCameraFOV

Sets the Player's Camera FOV (if not possessing a Character)
my_player:SetCameraFOV(fov?)

Parameters

TypeParameterDefaultDescription
floatfov?90Value must be between 5 and 170. Pass empty to reset to default.

SetCameraLocation

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

Parameters

TypeParameterDefaultDescription
Vectorlocation Required parameter No description provided

See also GetCameraLocation.


SetCameraRotation

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

Parameters

TypeParameterDefaultDescription
Rotatorrotation Required parameter No description provided

See also GetCameraRotation.


SetCameraSocketOffset

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

Parameters

TypeParameterDefaultDescription
Vectorsocket_offset Required parameter No description provided

SetCameraSpeedSettings

Sets the Player's Camera Speed Settings (if not possessing a Character)
my_player:SetCameraSpeedSettings(max_speed?, acceleration?, deceleration?, turning_boost?)

Parameters

TypeParameterDefaultDescription
floatmax_speed?1200Maximum velocity magnitude allowed
floatacceleration?4000Acceleration applied by input (rate of change of velocity)
floatdeceleration?4000Deceleration applied when there is no input (rate of change of velocity)
floatturning_boost?8Setting affecting extra force applied when changing direction, making turns have less drift and become more responsive. Velocity magnitude is not allowed to increase, that only happens due to normal acceleration. It may decrease with large direction changes. Larger values apply extra force to reach the target direction more quickly, while a zero value disables any extra turn force.

SetDimension

Sets this Player's dimension
my_player:SetDimension(dimension)

Parameters

TypeParameterDefaultDescription
integerdimension Required parameter No description provided

See also GetDimension, DimensionChange.


SetDistanceOptimizationMultiplier

Sets this Player's distance optimization multiplier.
A value of 0 disables optimization. Values under 1 decrease the effect, while values over 1 increase it
my_player:SetDistanceOptimizationMultiplier(multiplier)

Parameters

TypeParameterDefaultDescription
floatmultiplier Required parameter No description provided

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)

Parameters

TypeParameterDefaultDescription
floatin_fade_amount Required parameter Range [0..1], where 0 is fully transparent and 1 is fully opaque solid color.
Colorcolor Required parameter No description provided
booleanin_fade_audio Required parameter No description provided

SetName

Sets the player's name
my_player:SetName(player_name)

Parameters

TypeParameterDefaultDescription
stringplayer_name Required parameter No description provided

See also GetName.


SetVOIPGlobalAllChannelsSetting

Sets the VOIP setting for all global channels
my_player:SetVOIPGlobalAllChannelsSetting(setting)

Parameters

TypeParameterDefaultDescription
VOIPSettingsetting Required parameter No description provided

See also SetVOIPGlobalChannelSetting, GetVOIPListeningChannels, GetVOIPSpeakingChannels, VOIPGlobalChannelSettingChange.


SetVOIPGlobalChannelSetting

Sets the VOIP setting for a specific global channel
my_player:SetVOIPGlobalChannelSetting(channel, setting)

Parameters

TypeParameterDefaultDescription
integerchannel Required parameter 0-63
VOIPSettingsetting Required parameter No description provided

See also SetVOIPGlobalAllChannelsSetting, GetVOIPListeningChannels, GetVOIPSpeakingChannels, VOIPGlobalChannelSettingChange.


SetVOIPGlobalHighPassFilter

Sets the global VOIP high-pass filter threshold frequency. Set it to 0 to disable it
my_player:SetVOIPGlobalHighPassFilter(threshold)

Parameters

TypeParameterDefaultDescription
integerthreshold Required parameter No description provided

See also SetVOIPGlobalLowPassFilter.


SetVOIPGlobalLowPassFilter

Sets the global VOIP low-pass filter threshold frequency. Set it to 0 to disable it
my_player:SetVOIPGlobalLowPassFilter(threshold)

Parameters

TypeParameterDefaultDescription
integerthreshold Required parameter No description provided

See also SetVOIPGlobalHighPassFilter.


SetVOIPGlobalVolume

Sets the global VOIP volume. It only affects the global channels
my_player:SetVOIPGlobalVolume(volume)

Parameters

TypeParameterDefaultDescription
floatvolume Required parameter No description provided

SetVOIPLocalMaxDistance

Sets the local/proximity VOIP max distance. This also affects networking usage
my_player:SetVOIPLocalMaxDistance(max_distance)

Parameters

TypeParameterDefaultDescription
integermax_distance Required parameter Falloff Distance. Default is 3600

See also SetVOIPLocalSetting, SetVOIPLocalVolume.


SetVOIPLocalSetting

Sets the VOIP setting for the local/proximity
my_player:SetVOIPLocalSetting(setting)

Parameters

TypeParameterDefaultDescription
VOIPSettingsetting Required parameter No description provided

See also SetVOIPLocalMaxDistance, SetVOIPLocalVolume, VOIPLocalSettingChange.


SetVOIPLocalVolume

Sets the local/proximity VOIP input/output volume. It only affects the local/proximity channel
my_player:SetVOIPLocalVolume(volume)

Parameters

TypeParameterDefaultDescription
floatvolume Required parameter No description provided

See also SetVOIPLocalSetting, SetVOIPLocalMaxDistance, VOIPLocalSettingChange.


SetVOIPMuted

Mutes or unmutes VOIP for this player
my_player:SetVOIPMuted(is_muted)

Parameters

TypeParameterDefaultDescription
booleanis_muted Required parameter No description provided

See also IsVOIPMuted.


Spectate

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

Parameters

TypeParameterDefaultDescription
Playerplayer Required parameter No description provided
floatblend_speed?0No description provided

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?)

Parameters

TypeParameterDefaultDescription
floatfrom_alpha Required parameter Alpha at which to begin the fade. Range [0..1], where 0 is fully transparent and 1 is fully opaque solid color.
floatto_alpha Required parameter Alpha at which to finish the fade.
floatduration Required parameter How long the fade should take, in seconds.
Colorto_color Required parameter Color to fade to/from.
booleanshould_fade_audio?True to fade audio volume along with the alpha of the solid color.
booleanhold_when_finished?True for fade to hold at the ToAlpha until explicitly stopped (e.g. with StopCameraFade)

StopCameraFade

Stops camera fading.
my_player:StopCameraFade()

TranslateCameraTo

Smoothly moves the Player's Camera Location (only works if not possessing any Character)
my_player:TranslateCameraTo(location, time, exp?)

Parameters

TypeParameterDefaultDescription
Vectorlocation Required parameter No description provided
floattime Required parameter No description provided
floatexp?0Exponential used to smooth interp, use 0 for linear movement

UnPossess

Release the Player from the Character
my_player:UnPossess()

🚀 Events

Inherited Entity Events
Player inherits from Base Entity Class, sharing it's events:
Base Entityscripting-reference/classes/base-classes/entity
NameDescription
ClassRegisterTriggered when a new Class is registered with the Inheriting System
DestroyTriggered when an Entity is destroyed
SpawnTriggered when an Entity is spawned/created
ValueChangeTriggered when an Entity has a value changed with :SetValue()
NameDescription
DimensionChangeTriggered when a Player changes its dimension
PossessTriggered when Player starts controlling a Pawn (Character)
ReadyTriggered when Player is ready (the client fully joined, loaded the map and all entities and is ready to play)
UnPossessA Pawn (Character) was unpossessed from the Player
VOIPWhen a Player starts/ends using VOIP
VOIPGlobalChannelSettingChangeTriggered when a global VOIP channel setting changes for this player
VOIPLocalSettingChangeTriggered when the local VOIP setting changes for this player

DimensionChange

Triggered when a Player changes its dimension
Player.Subscribe("DimensionChange", function(self, old_dimension, new_dimension)
-- DimensionChange was called
end)

Arguments

TypeArgumentDescription
PlayerselfNo description provided
integerold_dimensionNo description provided
integernew_dimensionNo description provided

See also SetDimension, GetDimension.


Possess

Triggered when Player starts controlling a Pawn (Character)
Player.Subscribe("Possess", function(self, pawn)
-- Possess was called
end)

Arguments

TypeArgumentDescription
PlayerselfNo description provided
Base PawnpawnNo description provided

See also GetControlledCharacter.


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)

Arguments

TypeArgumentDescription
PlayerselfNo description provided

UnPossess

A Pawn (Character) was unpossessed from the Player
Player.Subscribe("UnPossess", function(self, pawn)
-- UnPossess was called
end)

Arguments

TypeArgumentDescription
PlayerselfNo description provided
Base PawnpawnNo description provided

See also GetControlledCharacter.


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
return true
end)

Arguments

TypeArgumentDescription
PlayerselfNo description provided
booleanis_talkingNo description provided

VOIPGlobalChannelSettingChange

Triggered when a global VOIP channel setting changes for this player
Player.Subscribe("VOIPGlobalChannelSettingChange", function(self, channel, old_setting, new_setting)
-- VOIPGlobalChannelSettingChange was called
end)

Arguments

TypeArgumentDescription
PlayerselfNo description provided
integerchannelNo description provided
VOIPSettingold_settingNo description provided
VOIPSettingnew_settingNo description provided

See also SetVOIPGlobalChannelSetting, SetVOIPGlobalAllChannelsSetting.


VOIPLocalSettingChange

Triggered when the local VOIP setting changes for this player
Player.Subscribe("VOIPLocalSettingChange", function(self, old_setting, new_setting)
-- VOIPLocalSettingChange was called
end)

Arguments

TypeArgumentDescription
PlayerselfNo description provided
VOIPSettingold_settingNo description provided
VOIPSettingnew_settingNo description provided

See also SetVOIPLocalSetting.