Skip to main content
Version: latest - a1.64.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.
🧑‍💻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!

Behörde

🟥 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
This class doesn't have own static functions.

🦠 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
CallRemoteEventCalls a custom remote event directly on this entity to a specific Player
CallRemoteEventCalls a custom remote event directly on this entity
DestroyDestroys this Entity
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
booleanIsARecursively checks if this entity is inherited from a Class
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
Character or nilGetControlledCharacterNo description provided
integerGetDimensionGets this Player's dimension
stringGetIPNo description provided
stringGetNameNo description provided
integerGetPingNo description provided
stringGetSteamIDNo description provided
integerGetVOIPChannelNo description provided
VOIPSettingGetVOIPSettingNo description provided
booleanIsHostNo description provided
booleanIsLocalPlayerNo description provided
KickKicks the player from the server
PossessMakes a Player to possess and control a 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)
integerSetDimensionSets this Player's dimension
SetManualCameraFadeTurns on camera fading at the given opacity
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
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)
TypeParameterDefaultDescription
Base Actoractor Required parameter No description provided
Vectorsocket_offset Required parameter No description provided
floatblend_speed Required parameter No description provided

Ban

Bans the player from the server

my_player:Ban(reason)
TypeParameterDefaultDescription
stringreason Required parameter No description provided

Connect

Redirects the player to another server

my_player:Connect(IP, password?)
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)

— Returns string.

local ret = my_player:GetAccountIconURL()

GetAccountID

— Returns string.

local ret = my_player:GetAccountID()

GetAccountName

— Returns string.

local ret = my_player:GetAccountName()

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().

See also SetCameraArmLength.


GetCameraLocation

— Returns Vector.

local ret = my_player:GetCameraLocation()

See also SetCameraLocation.


GetCameraRotation

— Returns Rotator.

local ret = my_player:GetCameraRotation()

See also SetCameraRotation.


GetControlledCharacter

— Returns Character or nil.

local ret = my_player:GetControlledCharacter()

GetDimension

Gets this Player's dimension

— Returns integer.

local ret = my_player:GetDimension()

See also SetDimension, DimensionChange.


GetIP

— Returns string.

local ret = my_player:GetIP()

GetName

— Returns string.

local ret = my_player:GetName()

See also SetName.


GetPing

— Returns integer.

local ret = my_player:GetPing()

GetSteamID

— Returns string.

local ret = my_player:GetSteamID()

GetVOIPChannel

— Returns integer.

local ret = my_player:GetVOIPChannel()

See also SetVOIPChannel.


GetVOIPSetting

— Returns VOIPSetting.

local ret = my_player:GetVOIPSetting()

See also SetVOIPSetting.


IsHost

— Returns boolean.

local ret = my_player:IsHost()

IsLocalPlayer

— Returns boolean.

local ret = my_player:IsLocalPlayer()

Kick

Kicks the player from the server

my_player:Kick(reason)
TypeParameterDefaultDescription
stringreason Required parameter No description provided

Possess

Makes a Player to possess and control a Character

my_player:Possess(new_character, blend_time?, exp?)
TypeParameterDefaultDescription
Characternew_character 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?)
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)
TypeParameterDefaultDescription
floatlength Required parameter No description provided
booleanforce Required parameter Whether 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?)
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)
TypeParameterDefaultDescription
Vectorlocation Required parameter No description provided

See also GetCameraLocation.


SetCameraRotation

Sets the Player's Camera Rotation

my_player:SetCameraRotation(rotation)
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)
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?)
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

— Returns integer.

local ret = my_player:SetDimension()

See also GetDimension, DimensionChange.


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_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)
TypeParameterDefaultDescription
stringplayer_name Required parameter No description provided

See also GetName.


SetVOIPChannel

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

my_player:SetVOIPChannel(channel)
TypeParameterDefaultDescription
integerchannel Required parameter No description provided

See also GetVOIPChannel.


SetVOIPSetting

Sets the VOIP Settings of this Player

my_player:SetVOIPSetting(voip_setting)
TypeParameterDefaultDescription
VOIPSettingvoip_setting Required parameter No description provided

See also GetVOIPSetting.


SetVOIPVolume

Sets the VOIP Volume of this Player

my_player:SetVOIPVolume(volume)
TypeParameterDefaultDescription
floatvolume Required parameter No description provided

Spectate

Spectates other Player

my_player:Spectate(player, blend_speed?)
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?)
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?)
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 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
PlayerselfNo description provided
integerold_dimensionNo description provided
integernew_dimensionNo description provided

See also SetDimension, GetDimension.


Possess

Trigerred when Player starts controlling a Character
Player.Subscribe("Possess", function(self, character)
-- Possess was called
end)
TypeArgumentDescription
PlayerselfNo description provided
CharactercharacterNo 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)
TypeArgumentDescription
PlayerselfNo description provided

UnPossess

A Character was released from the Player
Player.Subscribe("UnPossess", function(self, character)
-- UnPossess was called
end)
TypeArgumentDescription
PlayerselfNo description provided
CharactercharacterNo 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
end)
TypeArgumentDescription
PlayerselfNo description provided
booleanis_talkingNo description provided