Core scripts are written in Lua, using version 5.3.4 of the Lua library. Scripts are objects created and added to the hierarchy and/or templates, similar to other object types. Scripts added to the hierarchy will execute as soon as the game loads, while scripts inside templates execute with each newly spawned instance of the template.
Properties, functions, and events inherited by CoreObject types are listed below. Both properties and events are accessed with .propertyName and .eventName, while functions are accessed with :FunctionName(). Some types have class functions, which are accessed with .FunctionName().
At a high level, Core Lua types can be divided into two groups: Data structures and Objects. Data structures are owned by Lua, while Objects are owned by the engine and could be destroyed while still referenced by Lua. Objects all inherit from a single base type: Object. Data structures have no common parent. However, all data structures and Objects share a common type property, which is a string indicating its type. The value of the type property will match the section headings below, for example: "Ability", "Vector2", "CoreObject", etc. All Core types also share an IsA() function. The IsA() function can be passed a type name, and will return true if the value is that type or one of its subtypes, or will return false if it is not. For example, myObject:IsA("StaticMesh").
A lowercase type denotates a basic Lua type, such as string and boolean. You can learn more about Lua types from the official manual here. An uppercase type is a Core Type, such as Player and CoreObject.
Abilities are CoreObjects that can be added to Players and guide the Player's animation in sync with the Ability's state machine. Spawn an Ability with World.SpawnAsset() or add an Ability as a child of an Equipment/Weapon to have it be assigned to the Player automatically when that item is equipped.
Abilities can be activated by association with an Action Binding. Their internal state machine flows through the phases: Ready, Cast, Execute, Recovery and Cooldown. An Ability begins in the Ready state and transitions to Cast when its Binding (e.g. Left mouse click) is activated by the owning player. It then automatically flows from Cast to Execute, then Recovery and finally Cooldown. At each of these state transitions it fires a corresponding event.
Only one ability can be active at a time. By default, activating an ability will interrupt the currently active ability. The canBePrevented and preventsOtherAbilities properties can be used to customize interruption rules for competing abilities.
If an ability is interrupted during the Cast phase, it will immediately reset to the Ready state. If an ability is interrupted during the Execute or Recovery phase, the ability will immediately transition to the Cooldown phase.
Event
Return Type
Description
Tags
readyEvent
Event<Ability>
Fired when the Ability becomes ready. In this phase it is possible to activate it again.
None
castEvent
Event<Ability>
Fired when the Ability enters the Cast phase.
None
executeEvent
Event<Ability>
Fired when the Ability enters Execute phase.
None
recoveryEvent
Event<Ability>
Fired when the Ability enters Recovery.
None
cooldownEvent
Event<Ability>
Fired when the Ability enters Cooldown.
None
interruptedEvent
Event<Ability>
Fired when the Ability is interrupted.
None
tickEvent
Event<Ability, Number deltaTime>
Fired every tick while the Ability is active (isEnabled = true and phase is not ready).
None
Function
Return Type
Description
Tags
Activate()
None
Activates an Ability as if the button had been pressed.
Client-Only
Interrupt()
None
Changes an Ability from Cast phase to Ready phase. If the Ability is in either Execute or Recovery phases it instead goes to Cooldown phase.
None
GetCurrentPhase()
AbilityPhase
The current AbilityPhase for this Ability. These are returned as one of: AbilityPhase.READY, AbilityPhase.CAST, AbilityPhase.EXECUTE, AbilityPhase.RECOVERY and AbilityPhase.COOLDOWN.
None
GetPhaseTimeRemaining()
Number
Seconds left in the current phase.
None
GetTargetData()
AbilityTarget
Returns information about what the Player has targeted this phase.
None
SetTargetData(AbilityTarget)
None
Updates information about what the Player has targeted this phase. This can affect the execution of the Ability.
None
Property
Return Type
Description
Tags
isEnabled
bool
Turns an Ability on/off. It stays on the Player but is interrupted if isEnabled is set to false during an active Ability. True by default.
Read-Write
canActivateWhileDead
bool
Indicates if the Ability can be used while the owning Player is dead. False by default.
Read-Only
name
string
The name of the Ability.
Read-Only
actionBinding
string
Which action binding will cause the Ability to activate. Possible values of the bindings are listed on the Ability binding page.
Read-Only
owner
Player
Assigning an owner applies the Ability to that Player.
Read-Write
castPhaseSettings
AbilityPhaseSettings
Config data for the Cast phase (see below).
Read-Only
executePhaseSettings
AbilityPhaseSettings
Config data for the Execute phase.
Read-Only
recoveryPhaseSettings
AbilityPhaseSettings
Config data for the Recovery phase.
Read-Only
cooldownPhaseSettings
AbilityPhaseSettings
Config data for the Cooldown phase.
Read-Only
animation
string
Name of the animation the Player will play when the Ability is activated. Possible values: See Ability Animation for strings and other info.
Read-Only
canBePrevented
bool
Used in conjunction with the phase property preventsOtherAbilities so multiple abilities on the same Player can block each other during specific phases. True by default.
Each phase of an Ability can be configured differently, allowing complex and different Abilities. AbilityPhaseSettings is an Object.
Property
Return Type
Description
Tags
duration
Number
Length in seconds of the phase. After this time the Ability moves to the next phase. Can be zero. Default values per phase: 0.15, 0, 0.5 and 3.
Read-Only
canMove
bool
Is the Player allowed to move during this phase. True by default.
Read-Only
canJump
bool
Is the Player allowed to jump during this phase. False by default in Cast & Execute, default True in Recovery & Cooldown.
Read-Only
canRotate
bool
Is the Player allowed to rotate during this phase. True by default.
Read-Only
preventsOtherAbilities
bool
When true this phase prevents the Player from casting another Ability, unless that other Ability has canBePrevented set to False. True by default in Cast & Execute, false in Recovery & Cooldown.
Read-Only
isTargetDataUpdated
bool
If true, there will be updated target information at the start of the phase. Otherwise, target information may be out of date.
Read-Only
facingMode
AbilityFacingMode
How and if this Ability rotates the Player during execution. Cast and Execute default to "Aim", other phases default to "None". Options are: AbilityFacingMode.NONE, AbilityFacingMode.MOVEMENT, AbilityFacingMode.AIM
A data type containing information about what the Player has targeted during a phase of an Ability.
Constructor
Return Type
Description
Tags
AbilityTarget.New()
AbilityTarget
Constructs a new Ability Target data object.
None
Function
Return Type
Description
Tags
GetOwnerMovementRotation()
Rotation
Gets the direction the Player is moving.
None
SetOwnerMovementRotation(Rotation)
None
Sets the direction the Player faces, if Ability.facingMode is set to AbilityFacingMode.MOVEMENT.
None
GetAimPosition()
Vector3
Returns the world space position of the camera.
None
SetAimPosition(Vector3)
None
The world space location of the camera. Setting this currently has no effect on the Player's camera.
None
GetAimDirection()
Vector3
Returns the direction the camera is facing.
None
SetAimDirection(Vector3)
None
Sets the direction the camera is facing.
None
GetHitPosition()
Vector3
Returns the world space position of the object under the Player's reticle. If there is no object, a position under the reticle in the distance. If the Player doesn't have a reticle displayed, uses the center of the screen as if there was a reticle there.
None
SetHitPosition(Vector3)
None
Sets the hit position property. This may affect weapon behavior.
None
GetHitResult()
HitResult
Returns physics information about the point being targeted
None
SetHitResult(HitResult)
None
Sets the hit result property. Setting this value has no affect on the Ability.
None
Property
Return Type
Description
Tags
hitObject
Object
Object under the reticle, or center of the screen if no reticle is displayed. Can be a Player, StaticMesh, etc.
Read-Write
hitPlayer
Player
Convenience property that is the same as hitObject, but only if hitObject is a Player.
Read-Write
spreadHalfAngle
Number
Half-angle of cone of possible target space, in degrees.
Read-Write
spreadRandomSeed
Integer
Seed that can be used with RandomStream for deterministic RNG.
AreaLight is a Light that emits light from a rectangular plane. It also has properties for configuring a set of "doors" attached to the plane which affect the lit area in front of the plane.
Property
Return Type
Description
Tags
sourceWidth
Number
The width of the plane from which light is emitted. Must be greater than 0.
Read-Write, Dynamic
sourceHeight
Number
The height of the plane from which light is emitted. Must be greater than 0.
Read-Write, Dynamic
barnDoorAngle
Number
The angle of the barn doors, in degrees. Valid values are in the range from 0 to 90. Has no effect if barnDoorLength is 0.
Read-Write, Dynamic
barnDoorLength
Number
The length of the barn doors. Must be non-negative.
Audio is a CoreObject that wrap sound files. Most properties are exposed in the UI and can be set when placed in the editor, but some functionality (such as playback with fade in/out) requires Lua scripting.
Function
Return Type
Description
Tags
Play()
None
Begins sound playback.
Dynamic
Stop()
None
Stops sound playback.
Dynamic
FadeIn(Number time)
None
Starts playing and fades in the sound over the given time.
Dynamic
FadeOut(Number time)
None
Fades the sound out and stops over time seconds.
Dynamic
Property
Return Type
Description
Tags
isPlaying
bool
Returns if the sound is currently playing.
Read-Only
length
Number
Returns the length (in seconds) of the Sound.
Read-Only
currentPlaybackTime
Number
Returns the playback position (in seconds) of the sound.
Read-Only
isSpatializationEnabled
bool
Default true. Set to false to play sound without 3D positioning.
Read-Write, Dynamic
isAttenuationEnabled
bool
Default true, meaning sounds will fade with distance.
Read-Write, Dynamic
isOcclusionEnabled
bool
Default true. Changes attenuation if there is geometry between the player and the audio source.
Read-Write, Dynamic
isAutoPlayEnabled
bool
Default false. If set to true when placed in the editor (or included in a template), the sound will be automatically played when loaded.
Read-Only
isTransient
bool
Default false. If set to true, the sound will automatically destroy itself after it finishes playing.
Read-Write, Dynamic
isAutoRepeatEnabled
bool
Loops when playback has finished. Some sounds are designed to automatically loop, this flag will force others that don't. Useful for looping music.
Read-Write, Dynamic
pitch
Number
Default 1. Multiplies the playback pitch of a sound. Note that some sounds have clamped pitch ranges (0.2 to 1).
Read-Write, Dynamic
volume
Number
Default 1. Multiplies the playback volume of a sound. Note that values above 1 can distort sound, so if you're trying to balance sounds, experiment to see if scaling down works better than scaling up.
Read-Write, Dynamic
radius
Number
Default 0. If non-zero, will override default 3D spatial parameters of the sound. Radius is the distance away from the sound position that will be played at 100% volume.
Read-Write, Dynamic
falloff
Number
Default 0. If non-zero, will override default 3D spatial parameters of the sound. Falloff is the distance outside the radius over which the sound volume will gradually fall to zero.
Read-Write, Dynamic
fadeInTime
Number
Sets the fade in time for the audio. When the audio is played, it will start at zero volume, and fade in over this many seconds.
Read-Write, Dynamic
fadeOutTime
Number
Sets the fadeout time of the audio. When the audio is stopped, it will keep playing for this many seconds, as it fades out.
Read-Write, Dynamic
startTime
Number
The start time of the audio track. Default is 0. Setting this to anything else means that the audio will skip ahead that many seconds when played.
Camera is a CoreObject which is used both to configure Player Camera settings as well as to represent the position and rotation of the Camera in the world. Cameras can be configured in various ways, usually following a specific Player's view, but can also have a fixed orientation and/or position.
Each Player (on their client) can have a default Camera and an override Camera. If they have neither, camera behavior falls back to a basic third-person behavior. Default Cameras should be used for main gameplay while override Cameras are generally employed as a temporary view, such as a when the Player is sitting in a mounted turret.
Function
Return Type
Description
Tags
GetPositionOffset()
Vector3
An offset added to the camera or follow target's eye position to the Player's view.
None
SetPositionOffset(Vector3)
None
An offset added to the camera or follow target's eye position to the Player's view.
Dynamic
GetRotationOffset()
Rotation
A rotation added to the camera or follow target's eye position.
None
SetRotationOffset(Rotation)
None
A rotation added to the camera or follow target's eye position.
Dynamic
Property
Return Type
Description
Tags
followPlayer
Player
Which Player's view the camera should follow. Set to the local Player for a first or third person camera. Set to nil to detach.
Read-Write, Dynamic
isOrthographic
bool
Whether the camera uses an isometric (orthographic) view or perspective.
Read-Write, Dynamic
fieldOfView
Number
The field of view when using perspective view. Clamped between 1.0 and 170.0.
Read-Write, Dynamic
viewWidth
Number
The width of the view with an isometric view. Has a minimum value of 1.0.
Read-Write, Dynamic
useCameraSocket
bool
If you have a followPlayer, then use their camera socket. This is often preferable for first-person cameras, and gives a bit of view bob.
Read-Write, Dynamic
currentDistance
Number
The distance controlled by the Player with scroll wheel (by default).
Client-Only, Read-Write, Dynamic
isDistanceAdjustable
bool
Whether the Player can control their camera distance (with the mouse wheel by default). Creators can still access distance through currentDistance below, even if this value is false.
Read-Write, Dynamic
minDistance
Number
The minimum distance the Player can zoom in to.
Read-Write, Dynamic
maxDistance
Number
The maximum distance the Player can zoom out to.
Read-Write, Dynamic
rotationMode
enum
Which base rotation to use. Values: RotationMode.CAMERA, RotationMode.NONE, RotationMode.LOOK_ANGLE.
Read-Write, Dynamic
hasFreeControl
bool
Whether the Player can freely control their rotation (with mouse or thumbstick). This has no effect if the camera is following a player.
Read-Write, Dynamic
currentPitch
Number
The current pitch of the Player's free control.
Client-Only, Read-Write, Dynamic
minPitch
Number
The minimum pitch for free control.
Read-Write, Dynamic
maxPitch
Number
The maximum pitch for free control.
Read-Write, Dynamic
isYawLimited
bool
Whether the Player's yaw has limits. If so, maxYaw must be at least minYaw, (and should be outside the range [0, 360] if needed).
CoreObject is an Object placed in the scene hierarchy during edit mode or is part of a template. Usually they'll be a more specific type of CoreObject, but all CoreObjects have these properties and functions:
Event
Return Type
Description
Tags
childAddedEvent
Event<CoreObject parent, CoreObject newChild>
Fired when a child is added to this object.
None
childRemovedEvent
Event<CoreObject parent, CoreObject removedChild>
Fired when a child is removed from this object.
None
descendantAddedEvent
Event<CoreObject ancestor, CoreObject newChild>
Fired when a child is added to this object or any of its descendants.
Fired when a child is removed from this object or any of its descendants.
None
destroyEvent
Event<CoreObject>
Fired when this object is about to be destroyed.
None
networkedPropertyChangedEvent
Event<CoreObject owner, string propertyName>
Fired whenever any of the networked custom properties on this object receive an update. The event is fired on the server and the client. Event payload is the owning object and the name of the property that just changed.
None
Function
Return Type
Description
Tags
GetTransform()
Transform
The Transform relative to this object's parent.
None
SetTransform(Transform)
None
The Transform relative to this object's parent.
Dynamic
GetPosition()
Vector3
The position of this object relative to its parent.
None
SetPosition(Vector3)
None
The position of this object relative to its parent.
Dynamic
GetRotation()
Rotation
The rotation relative to its parent.
None
SetRotation(Rotation)
None
The rotation relative to its parent.
Dynamic
GetScale()
Vector3
The scale relative to its parent.
None
SetScale(Vector3)
None
The scale relative to its parent.
Dynamic
GetWorldTransform()
Transform
The absolute Transform of this object.
None
SetWorldTransform(Transform)
None
The absolute Transform of this object.
Dynamic
GetWorldPosition()
Vector3
The absolute position.
None
SetWorldPosition(Vector3)
None
The absolute position.
Dynamic
GetWorldRotation()
Rotation
The absolute rotation.
None
SetWorldRotation(Rotation)
None
The absolute rotation.
Dynamic
GetWorldScale()
Vector3
The absolute scale.
None
SetWorldScale(Vector3)
None
The absolute scale.
Dynamic
GetVelocity()
Vector3
The object's velocity in world space.
None
SetVelocity(Vector3)
None
Set the object's velocity in world space. Only works for physics objects.
Dynamic
GetAngularVelocity()
Vector3
The object's angular velocity in degrees per second.
None
SetAngularVelocity(Vector3)
None
Set the object's angular velocity in degrees per second in world space. Only works for physics objects.
Dynamic
SetLocalAngularVelocity(Vector3)
None
Set the object's angular velocity in degrees per second in local space. Only works for physics objects.
Dynamic
GetReference()
CoreObjectReference
Returns a CoreObjectReference pointing at this object.
None
GetChildren()
Array<CoreObject>
Returns a table containing the object's children, may be empty.
None
IsVisibleInHierarchy()
bool
Returns true if this object and all of its ancestors are visible.
None
IsCollidableInHierarchy()
bool
Returns true if this object and all of its ancestors are collidable.
None
IsEnabledInHierarchy()
bool
Returns true if this object and all of its ancestors are enabled.
None
FindAncestorByName(string name)
CoreObject
Returns the first parent or ancestor whose name matches the provided name. If none match, returns nil.
None
FindChildByName(string name)
CoreObject
Returns the first immediate child whose name matches the provided name. If none match, returns nil.
None
FindDescendantByName(string name)
CoreObject
Returns the first child or descendant whose name matches the provided name. If none match, returns nil.
None
FindDescendantsByName(string name)
Array<CoreObject>
Returns the descendants whose name matches the provided name. If none match, returns an empty table.
None
FindAncestorByType(string typeName)
CoreObject
Returns the first parent or ancestor whose type is or extends the specified type. For example, calling FindAncestorByType('CoreObject') will return the first ancestor that is any type of CoreObject, while FindAncestorByType('StaticMesh') will only return the first mesh. If no ancestors match, returns nil.
None
FindChildByType(string typeName)
CoreObject
Returns the first immediate child whose type is or extends the specified type. If none match, returns nil.
None
FindDescendantByType(string typeName)
CoreObject
Returns the first child or descendant whose type is or extends the specified type. If none match, returns nil.
None
FindDescendantsByType(string typeName)
Array<CoreObject>
Returns the descendants whose type is or extends the specified type. If none match, returns an empty table.
None
FindTemplateRoot()
CoreObject
If the object is part of a template, returns the root object of the template (which may be itself). If not part of a template, returns nil.
None
IsAncestorOf(CoreObject)
bool
Returns true if this CoreObject is a parent somewhere in the hierarchy above the given parameter object. False otherwise.
None
GetCustomProperties()
table
Returns a table containing the names and values of all custom properties on a CoreObject.
None
GetCustomProperty(string propertyName)
value, bool
Gets data which has been added to an object using the custom property system. Returns the value, which can be an Integer, Number, bool, string, Vector3, Rotator, Color, a MUID string, or nil if not found. Second return value is a bool, true if found and false if not.
Sets the named custom property if it is marked as replicated and the object it belongs to is server-side networked or in a client/server context.
Server-Only
AttachToPlayer(Player, string socketName)
None
Attaches a CoreObject to a Player at a specified socket. The CoreObject will be un-parented from its current hierarchy and its parent property will be nil. See Socket Names for the list of possible values.
Dynamic
AttachToLocalView()
None
Attaches a CoreObject to the local player's camera. Reminder to turn off the object's collision otherwise it will cause camera to jitter.
Client-Only, Dynamic
Detach()
None
Detaches a CoreObject from any player it has been attached to, or from its parent object.
Dynamic
GetAttachedToSocketName()
string
Returns the name of the socket this object is attached to.
None
MoveTo(Vector3, Number, [bool])
None
Smoothly moves the object to the target location over a given amount of time (seconds). Third parameter specifies if the given destination is in local space (true) or world space (false).
Dynamic
RotateTo(Rotation/Quaternion, Number, [bool])
None
Smoothly rotates the object to the target orientation over a given amount of time. Third parameter specifies if given rotation is in local space (true) or world space (false).
Dynamic
ScaleTo(Vector3, Number, [bool])
None
Smoothly scales the object to the target scale over a given amount of time. Third parameter specifies if the given scale is in local space (true) or world space (false).
Dynamic
MoveContinuous(Vector3, [bool])
None
Smoothly moves the object over time by the given velocity vector. Second parameter specifies if the given velocity is in local space (true) or world space (false).
Smoothly rotates the object over time by the given angular velocity. The second parameter is an optional multiplier, for very fast rotations. Third parameter specifies if the given rotation or quaternion is in local space (true) or world space (false (default)).
Dynamic
ScaleContinuous(Vector3, [bool])
None
Smoothly scales the object over time by the given scale vector per second. Second parameter specifies if the given scale rate is in local space (true) or world space (false).
Dynamic
StopMove()
None
Interrupts further movement from MoveTo(), MoveContinuous(), or Follow().
Dynamic
StopRotate()
None
Interrupts further rotation from RotateTo(), RotateContinuous(), LookAtContinuous(), or LookAtLocalView().
Dynamic
StopScale()
None
Interrupts further movement from ScaleTo() or ScaleContinuous().
Dynamic
Follow(Object, [Number, [Number]])
None
Follows a CoreObject or Player at a certain speed. If the speed is not supplied it will follow as fast as possible. The third parameter specifies a distance to keep away from the target.
Dynamic
LookAt(Vector3 position)
None
Instantly rotates the object to look at the given position.
Dynamic
LookAtContinuous(Object, [bool], [Number])
None
Smoothly rotates a CoreObject to look at another given CoreObject or Player. Second parameter is optional and locks the pitch, default is unlocked. Third parameter is optional and sets how fast it tracks the target. If speed is not supplied it tracks as fast as possible.
Dynamic
LookAtLocalView([bool])
None
Continuously looks at the local camera. The bool parameter is optional and locks the pitch. (Client-only)
Client-Only, Dynamic
Destroy()
None
Destroys the object and all descendants. You can check whether an object has been destroyed by calling Object.IsValid(object), which will return true if object is still a valid object, or false if it has been destroyed.
Dynamic
Property
Return Type
Description
Tags
name
string
The object's name as seen in the Hierarchy.
Read-Write, Dynamic
id
string
The object's MUID.
Read-Only
parent
CoreObject
The object's parent object, may be nil.
Read-Write, Dynamic
visibility
enum
Turn on/off the rendering of an object and its children. Values: Visibility.FORCE_ON, Visibility.FORCE_OFF, Visibility.INHERIT.
Read-Write, Dynamic
collision
enum
Turn on/off the collision of an object and its children. Values: Collision.FORCE_ON, Collision.FORCE_OFF, Collision.INHERIT.
Read-Write, Dynamic
isEnabled
bool
Turn on/off an object and its children completely.
Read-Write, Dynamic
isStatic
bool
If true, dynamic properties may not be written to, and dynamic functions may not be called.
Read-Only, Dynamic
isClientOnly
bool
If true, this object was spawned on the client and is not replicated from the server.
Read-Only
isServerOnly
bool
If true, this object was spawned on the server and is not replicated to clients.
Read-Only
isNetworked
bool
If true, this object replicates from the server to clients.
Read-Only
lifeSpan
Number
Duration after which the object is destroyed.
Read-Write, Dynamic
sourceTemplateId
string
The ID of the Template from which this CoreObject was instantiated. nil if the object did not come from a Template.
A reference to a CoreObject which may or may not exist. This type is returned by CoreObject:GetCustomProperty() for CoreObject Reference properties, and may be used to find the actual object if it exists.
In the case of networked objects it's possible to get a CoreObjectReference pointing to a CoreObject that hasn't been received on the client yet.
Function
Return Type
Description
Tags
GetObject()
CoreObject
Returns the CoreObject with a matching ID, if it exists. Will otherwise return nil.
None
WaitForObject([Number])
CoreObject
Returns the CoreObject with a matching ID, if it exists. If it does not, yields the current task until the object is spawned. Optional timeout parameter will cause the task to resume with a return value of false and an error message if the object has not been spawned within that many seconds.
None
Property
Return Type
Description
Tags
id
string
The MUID of the referred object.
Read-Only
isAssigned
bool
Returns true if this reference has been assigned a valid ID. This does not necessarily mean the object currently exists.
To damage a Player, you can simply write e.g.: whichPlayer:ApplyDamage(Damage.New(10)). Alternatively, create a Damage object and populate it with all the following properties to get full use out of the system:
Constructor
Return Type
Description
Tags
Damage.New([Number amount])
Damage
Constructs a damage object with the given number, defaults to 0.
None
Function
Return Type
Description
Tags
GetHitResult()
HitResult
Get the HitResult information if this damage was caused by a Projectile impact.
None
SetHitResult(HitResult)
None
Forward the HitResult information if this damage was caused by a Projectile impact.
None
Property
Return Type
Description
Tags
amount
Number
The numeric amount of damage to inflict.
Read-Write
reason
DamageReason
What is the context for this Damage? DamageReason.UNKNOWN (default value), DamageReason.COMBAT, DamageReason.FRIENDLY_FIRE, DamageReason.MAP, DamageReason.NPC.
Read-Write
sourceAbility
Ability
Reference to the Ability which caused the Damage. Setting this allows other systems to react to the damage event, e.g. a kill feed can show what killed a Player.
Read-Write
sourcePlayer
Player
Reference to the Player who caused the Damage. Setting this allows other systems to react to the damage event, e.g. a kill feed can show who killed a Player.
Equipment is a CoreObject representing an equippable item for players. They generally have a visual component that attaches to the Player, but a visual component is not a requirement. Any Ability objects added as children of the Equipment are added/removed from the Player automatically as it becomes equipped/unequipped.
Event
Return Type
Description
Tags
equippedEvent
Event<Equipment, Player>
Fired when this equipment is equipped onto a player.
None
unequippedEvent
Event<Equipment, Player>
Fired when this object is unequipped from a player.
None
Function
Return Type
Description
Tags
Equip(Player)
None
Attaches the Equipment to a Player. They gain any abilities assigned to the Equipment. If the Equipment is already attached to another Player it will first unequip from that other Player before equipping unto the new one.
None
Unequip()
None
Detaches the Equipment from any Player it may currently be attached to. The Player loses any abilities granted by the Equipment.
None
AddAbility(Ability)
None
Adds an Ability to the list of abilities on this Equipment.
None
GetAbilities()
Array<Ability>
A table of Abilities that are assigned to this Equipment. Players who equip it will get these Abilities.
None
Property
Return Type
Description
Tags
socket
string
Determines which point on the avatar's body this equipment will be attached. See Socket Names for the list of possible values.
Events appear as properties on several objects. The goal is to register a function that will be fired whenever that event happens. E.g. playerA.damagedEvent:Connect(OnPlayerDamaged) chooses the function OnPlayerDamaged to be fired whenever playerA takes damage.
Function
Return Type
Description
Tags
Connect(function eventListener, [...])
EventListener
Registers the given function which will be called every time the event is fired. Returns an EventListener which can be used to disconnect from the event or check if the event is still connected. Accepts any number of additional arguments after the listener function, those arguments will be provided after the event's own parameters.
A data structure containing all information about a specific Weapon interaction, such as collision with a character.
Function
Return Type
Description
Tags
GetHitResult()
HitResult
Physics information about the impact between the Weapon and the other object.
None
GetHitResults()
Array<HitResult>
Table with multiple HitResults that hit the same object, in the case of Weapons with multi-shot (e.g. Shotguns). If a single attack hits multiple targets you receive a separate interaction event for each object hit.
None
Property
Return Type
Description
Tags
targetObject
Object
Reference to the CoreObject/Player hit by the Weapon.
Read-Only
projectile
Projectile
Reference to a Projectile, if one was produced as part of this interaction.
Read-Only
sourceAbility
Ability
Reference to the Ability which initiated the interaction.
Read-Only
weapon
Weapon
Reference to the Weapon that is interacting.
Read-Only
weaponOwner
Player
Reference to the Player who had the Weapon equipped at the time it was activated, ultimately leading to this interaction.
Read-Only
travelDistance
Number
The distance in cm between where the Weapon attack started until it impacted something.
Read-Only
isHeadshot
bool
True if the Weapon hit another player in the head.
Light is a light source that is a CoreObject. Generally a Light will be an instance of some subtype, such as PointLight or SpotLight.
Function
Return Type
Description
Tags
GetColor()
Color
The color of the light.
None
SetColor(Color)
None
The color of the light.
Dynamic
Property
Return Type
Description
Tags
intensity
Number
The intensity of the light. For PointLights and SpotLights, this has two interpretations, depending on the value of the hasNaturalFallOff property. If true, the light's Intensity is in units of lumens, where 1700 lumens is a 100W lightbulb. If false, the light's Intensity is a brightness scale.
Read-Write, Dynamic
attenuationRadius
Number
Bounds the light's visible influence. This clamping of the light's influence is not physically correct but very important for performance, larger lights cost more.
Read-Write, Dynamic
isShadowCaster
bool
Does this light cast shadows?
Read-Write, Dynamic
hasTemperature
bool
true: use temperature value as illuminant. false: use white (D65) as illuminant.
Read-Write, Dynamic
temperature
Number
Color temperature in Kelvin of the blackbody illuminant. White (D65) is 6500K.
Read-Write, Dynamic
team
Integer
Assigns the light to a team. Value range from 0 to 4. 0 is a neutral team.
Read-Write, Dynamic
isTeamColorUsed
bool
If true, and the light has been assigned to a valid team, players on that team will see a blue light, while other players will see red.
At a high level, Core Lua types can be divided into two groups: data structures and Objects. Data structures are owned by Lua, while Objects are owned by the engine and could be destroyed while still referenced by Lua. Any such object will inherit from this type. These include CoreObject, Player and Projectile.
Class Function
Return Type
Description
Tags
Object.IsValid(Object object)
bool
Returns true if object is still a valid Object, or false if it has been destroyed. Also returns false if passed a nil value or something that's not an Object, such as a Vector3 or a string.
None
Property
Return Type
Description
Tags
serverUserData
table
Table in which users can store any data they want on the server.
Server-Only, Read-Write
clientUserData
table
Table in which users can store any data they want on the client.
Player is an Object representation of the state of a Player connected to the game, as well as their avatar in the world.
Event
Return Type
Description
Tags
damagedEvent
Event<Player, Damage>
Fired when the Player takes damage.
Server-Only
diedEvent
Event<Player, Damage>
Fired when the Player dies.
Server-Only
respawnedEvent
Event<Player>
Fired when the Player respawns.
None
bindingPressedEvent
Event<Player, string>
Fired when an action binding is pressed. Second parameter tells you which binding. Possible values of the bindings are listed on the Ability binding page.
None
bindingReleasedEvent
Event<Player, string>
Fired when an action binding is released. Second parameter tells you which binding.
None
resourceChangedEvent
Event<Player, string, Integer>
Fired when a resource changed, indicating the type of the resource and its new amount.
None
movementModeChangedEvent
Event<Player, MovementMode, MovementMode>
Fired when a Player's movement mode changes. The first parameter is the Player being changed. The second parameter is the "new" movement mode. The third parameter is the "previous" movement mode. Possible values for MovementMode are: MovementMode.NONE, MovementMode.WALKING, MovementMode.FALLING, MovementMode.SWIMMING, MovementMode.FLYING and MovementMode.SLIDING.
None
animationEvent
Event<Player, string eventName>
Fired during certain animations played on a player.
Client-Only
Function
Return Type
Description
Tags
GetWorldTransform()
Transform
The absolute Transform of this player.
None
SetWorldTransform(Transform)
None
The absolute Transform of this player.
Server-Only
GetWorldPosition()
Vector3
The absolute position of this player.
None
SetWorldPosition(Vector3)
None
The absolute position of this player.
Server-Only
GetWorldRotation()
Rotation
The absolute rotation of this player.
None
SetWorldRotation(Rotation)
None
The absolute rotation of this player.
Server-Only
GetWorldScale()
Vector3
The absolute scale of this player.
None
SetWorldScale(Vector3)
None
The absolute scale of this player (must be uniform).
Server-Only
AddImpulse(Vector3)
None
Adds an impulse force to the Player.
Server-Only
GetVelocity()
Vector3
Gets the current velocity of the Player.
None
SetVelocity(Vector3)
None
Sets the Player's velocity to the given amount.
Server-Only
ResetVelocity()
None
Resets the Player's velocity to zero.
Server-Only
GetAbilities()
Array<Ability>
Array of all Abilities assigned to this Player.
None
GetEquipment()
Array<Equipment>
Array of all Equipment assigned to this Player.
None
ApplyDamage(Damage)
None
Damages a Player. If their hit points go below 0 they die.
Server-Only
Die([Damage])
None
Kills the Player. They will ragdoll and ignore further Damage. The optional Damage parameter is a way to communicate cause of death.
Server-Only
DisableRagdoll()
None
Disables all ragdolls that have been set on the Player.
Server-Only
SetVisibility(bool, [bool])
None
Shows or hides the Player. The second parameter is optional, defaults to true, and determines if attachments to the Player are hidden as well as the Player.
Server-Only
GetVisibility()
bool
Returns whether or not the Player is hidden.
None
EnableRagdoll([string socketName, Number weight])
None
Enables ragdoll for the Player, starting on socketName weighted by weight (between 0.0 and 1.0). This can cause the Player capsule to detach from the mesh. All parameters are optional; socketName defaults to the root and weight defaults to 1.0. Multiple bones can have ragdoll enabled simultaneously. See Socket Names for the list of possible values.
Server-Only
Respawn([Vector, Rotation])
None
Resurrects a dead Player based on respawn settings in the game (default in-place). Optional position and rotation parameters can be used to specify a location.
Server-Only
GetViewWorldPosition()
Vector3
Get position of the Player's camera view.
Client-Only
GetViewWorldRotation()
Rotation
Get rotation of the Player's camera view.
Client-Only
GetLookWorldRotation()
Rotation
Get the rotation for the direction the Player is facing.
None
SetLookWorldRotation(Rotation)
None
Set the rotation for the direction the Player is facing.
Client-Only
ClearResources()
None
Removes all resources from a player.
Server-Only
GetResources()
Table<string, Integer>
Returns a table containing the names and amounts of the player's resources.
None
GetResource(string name)
Integer
Returns the amount of a resource owned by a player. Returns 0 by default.
None
SetResource(string name, Integer amount)
None
Sets a specific amount of a resource on a player.
Server-Only
AddResource(string name, Integer amount)
None
Adds an amount of a resource to a player.
Server-Only
RemoveResource(string name, Integer amount)
None
Subtracts an amount of a resource from a player. Does not go below 0.
Server-Only
TransferToGame(string)
None
Does not work in preview mode or in games played locally. Transfers player to the game specified by the passed-in game ID. Example: The game ID for the URL https://www.coregames.com/games/577d80/core-royale is 577d80/core-royale.
Server-Only
GetAttachedObjects()
Array<CoreObject>
Returns a table containing CoreObjects attached to this player.
None
SetMounted(bool)
None
Forces a player in or out of mounted state.
Server-Only
GetActiveCamera()
Camera
Returns whichever camera is currently active for the Player.
Client-Only
GetDefaultCamera()
Camera
Returns the default Camera object the Player is currently using.
Client-Only
SetDefaultCamera(Camera, [Number lerpTime = 0.0])
None
Sets the default Camera object for the Player.
Client-Only
GetOverrideCamera()
Camera
Returns the override Camera object the Player is currently using.
Clears the override Camera object for the Player (to revert back to the default camera).
Client-Only
ActivateFlying()
None
Activates the Player flying mode.
Server-Only
ActivateWalking()
None
Activate the Player walking mode.
Server-Only
Property
Return Type
Description
Tags
name
string
The Player's name.
Read-Write
id
string
The unique id of the Player. Consistent across sessions.
Read-Only
team
Integer
The number of the team to which the Player is assigned. By default, this value is 255 in FFA mode.
Read-Write
animationStance
string
Which set of animations to use for this Player. See Animation Stance Strings for possible values.
Read-Write
currentFacingMode
FacingMode
Current mode applied to player, including possible overrides. Possible values are FacingMode.FACE_AIM_WHEN_ACTIVE, FacingMode.FACE_AIM_ALWAYS, and FacingMode.FACE_MOVEMENT. See desiredFacingMode for details.
Read-Only
desiredFacingMode
FacingMode
Which controls mode to use for this Player. May be overridden by certain movement modes like MovementMode.SWIMMING or when mounted. Possible values are FacingMode.FACE_AIM_WHEN_ACTIVE, FacingMode.FACE_AIM_ALWAYS, and FacingMode.FACE_MOVEMENT.
Server-Only, Read-Write
defaultRotationRate
Rotation
Determines how quickly the Player turns to match the camera's look. Set to -1 for immediate rotation. Currently only supports rotation around the Z-axis.
Server-Only, Read-Write
currentRotationRate
Rotation
Reports the real rotation rate that results from any active mechanics/movement overrides.
Read-Only
hitPoints
Number
Current amount of hitpoints.
Read-Write
maxHitPoints
Number
Maximum amount of hitpoints.
Read-Write
kills
Integer
The number of times the player has killed another player.
Read-Write
deaths
Integer
The number of times the player has died.
Read-Write
stepHeight
Number
Maximum height in centimeters the Player can step up. Range is 0-100. Default = 45.
Read-Write
maxWalkSpeed
Number
Maximum speed while the player is on the ground. Default = 640.
Read-Write
maxAcceleration
Number
Max Acceleration (rate of change of velocity). Default = 1200.
Read-Write
brakingDecelerationFalling
Number
Deceleration when falling and not applying acceleration. Default = 0.
Read-Write
brakingDecelerationWalking
Number
Deceleration when walking and movement input has stopped. Default = 512.0.
Read-Write
groundFriction
Number
Friction when walking on ground. Default = 8.0
Read-Write
brakingFrictionFactor
Number
Multiplier for friction when braking. Default = 0.6.
Read-Write
walkableFloorAngle
Number
Max walkable floor angle, in degrees. Default = 44.765.
Read-Write
maxJumpCount
Integer
Max number of jumps, to enable multiple jumps. Set to 0 to disable jumping.
Read-Write
jumpVelocity
Number
Vertical speed applied to Player when they jump.
Read-Write
gravityScale
Number
Multiplier on gravity applied. Default = 1.9.
Read-Write
maxSwimSpeed
Number
Maximum speed while the player is swimming. Default = 420.
Read-Write
touchForceFactor
Number
Force applied to physics objects when contacted with a Player. Default = 1.
Read-Write
isCrouchEnabled
bool
Turns crouching on/off for a Player.
Read-Write
mass
Number
Gets the mass of the Player.
Read-Only
isAccelerating
bool
True if the Player is accelerating, such as from input to move.
Read-Only
isCrouching
bool
True if the Player is crouching.
Read-Only
isFlying
bool
True if the Player is flying.
Read-Only
isGrounded
bool
True if the Player is on the ground with no upward velocity, otherwise false.
Read-Only
isJumping
bool
True if the Player is jumping.
Read-Only
isMounted
bool
True if the Player is mounted on another object.
Read-Only
isSwimming
bool
True if the Player is swimming in water.
Read-Only
isWalking
bool
True if the Player is in walking mode.
Read-Only
isDead
bool
True if the Player is dead, otherwise false.
Read-Only
isSliding
bool
True if the Player is currently in sliding mode.
Read-Only
movementControlMode
MovementControlMode
Specify how players control their movement. Default: MovementControlMode.LOOK_RELATIVE. MovementControlMode.NONE: Movement input is ignored. MovementControlMode.LOOK_RELATIVE: Forward movement follows the current player's look direction. MovementControlMode.VIEW_RELATIVE: Forward movement follows the current view's look direction. MovementControlMode.FACING_RELATIVE: Forward movement follows the current player's facing direction. MovementControlMode.FIXED_AXES: Movement axis are fixed.
Read-Write
lookControlMode
LookControlMode
Specify how players control their look direction. Default: LookControlMode.RELATIVE. LookControlMode.NONE: Look input is ignored. LookControlMode.RELATIVE: Look input controls the current look direction. LookControlMode.LOOK_AT_CURSOR: Look input is ignored. The player's look direction is determined by drawing a line from the player to the cursor on the Cursor Plane.
Read-Write
lookSensitivity
Number
Multiplier on the Player look rotation speed relative to cursor movement. This is independent from user's preferences, both will be applied as multipliers together. Default = 1.0.
Read-Write
spreadModifier
Number
Modifier added to the Player's targeting spread.
Read-Write
currentSpread
Number
Gets the Player's current targeting spread.
Client-Only, Read-Only
buoyancy
Number
In water, buoyancy 1.0 is neutral (won't sink or float naturally). Less than 1 to sink, greater than 1 to float.
Read-Write
canMount
bool
Returns whether the Player can manually toggle on/off the mount.
Server-Only, Read-Write
shouldDismountWhenDamaged
bool
If true, and the Player is mounted they will dismount if they take damage.
Server-Only, Read-Write
isVisibleToSelf
bool
Set whether to hide the Player model on Player's own client, for sniper scope, etc.
PointLight is a placeable light source that is a CoreObject.
Property
Return Type
Description
Tags
hasNaturalFalloff
bool
The attenuation method of the light. When enabled, attenuationRadius is used. When disabled, falloffExponent is used. Also changes the interpretation of the intensity property, see intensity for details.
Read-Write, Dynamic
falloffExponent
Number
Controls the radial falloff of the light when hasNaturalFalloff is false. 2.0 is almost linear and very unrealistic and around 8.0 it looks reasonable. With large exponents, the light has contribution to only a small area of its influence radius but still costs the same as low exponents.
Projectile is a specialized Object which moves through the air in a parabolic shape and impacts other objects. To spawn a Projectile, use Projectile.Spawn().
Spawns a Projectile with a child that is an instance of a template.
None
Event
Return Type
Description
Tags
impactEvent
Event<Projectile, Object other, HitResult>
Fired when the Projectile collides with something. Impacted object parameter will be either of type CoreObject or Player, but can also be nil. The HitResult describes the point of contact between the Projectile and the impacted object.
None
lifeSpanEndedEvent
Event<Projectile>
Fired when the Projectile reaches the end of its lifespan. Fired before it is destroyed.
None
homingFailedEvent
Event<Projectile>
Fired when the target is no longer valid, for example the Player disconnected from the game or the object was destroyed somehow.
None
Function
Return Type
Description
Tags
Destroy()
Object
Immediately destroys the object.
None
GetWorldTransform()
Transform
Transform data for the Projectile in world space.
None
GetWorldPosition()
Vector3
Position of the Projectile in world space.
None
SetWorldPosition(Vector3)
None
Position of the Projectile in world space.
None
GetVelocity()
Vector3
Current direction and speed vector of the Projectile.
None
SetVelocity(Vector3)
None
Current direction and speed vector of the Projectile.
None
Property
Return Type
Description
Tags
owner
Player
The Player who fired this Projectile. Setting this property ensures the Projectile does not impact the owner or their allies. This will also change the color of the Projectile if teams are being used in the game.
Read-Write
sourceAbility
Ability
Reference to the Ability from which the Projectile was created.
Read-Write
speed
Number
Centimeters per second movement. Default 5000.
Read-Write
maxSpeed
Number
Max cm/s. Default 0. Zero means no limit.
Read-Write
gravityScale
Number
How much drop. Default 1. 1 means normal gravity. Zero can be used to make a Projectile go in a straight line.
Read-Write
drag
Number
Deceleration. Important for homing Projectiles (try a value around 5). Negative drag will cause the Projectile to accelerate. Default 0.
Read-Write
bouncesRemaining
Integer
Number of bounces remaining before it dies. Default 0.
Read-Write
bounciness
Number
Velocity % maintained after a bounce. Default 0.6.
Read-Write
lifeSpan
Number
Max seconds the Projectile will exist. Default 10.
Read-Write
shouldBounceOnPlayers
bool
Determines if the Projectile should bounce off players or be destroyed, when bouncesRemaining is used. Default false.
Read-Write
piercesRemaining
Integer
Number of objects that will be pierced before it dies. A piercing Projectile loses no velocity when going through objects, but still fires the impactEvent event. If combined with bounces, all piercesRemaining are spent before bouncesRemaining are counted. Default 0.
Read-Write
capsuleRadius
Number
Shape of the Projectile's collision. Default 22.
Read-Write
capsuleLength
Number
Shape of the Projectile's collision. A value of zero will make it shaped like a Sphere. Default 44.
Read-Write
homingTarget
CoreObject
The projectile accelerates towards its target. Homing targets are meant to be used with spawned projectiles and will not work with weapons.
Read-Write
homingAcceleration
Number
Magnitude of acceleration towards the target. Default 10,000.
Read-Write
shouldDieOnImpact
bool
If true, the Projectile is automatically destroyed when it hits something, unless it has bounces remaining. Default true.
Seed-based random stream of numbers. Useful for deterministic RNG problems, for instance, inside a Client Context so all players get the same outcome without the need to replicate lots of data from the server. Bad quality in the lower bits (avoid combining with modulus operations).
Constructor
Return Type
Description
Tags
RandomStream.New([Integer seed])
RandomStream
Constructor with specified seed, defaults to 0.
None
Function
Return Type
Description
Tags
GetInitialSeed()
Integer
The seed that was used to initialize this stream.
None
Reset()
None
Function that sets the seed back to the initial seed.
None
Mutate()
None
Moves the seed forward to the next seed.
None
GetNumber([Number min, Number max])
Number
Returns a floating point number between min and max (inclusive), defaults to 0 and 1 (exclusive).
None
GetInteger(Integer min, Integer max)
Number
Returns an integer number between min and max (inclusive).
None
GetVector3()
Vector3
Returns a random unit vector.
None
GetVector3FromCone(Vector3 direction, Number halfAngle)
Vector3
Returns a random unit vector, uniformly distributed, from inside a cone defined by direction and halfAngle (in degrees).
None
GetVector3FromCone(Vector3 direction, Number horizontalHalfAngle, Number verticalHalfAngle)
Vector3
Returns a random unit vector, uniformly distributed, from inside a cone defined by direction, horizontalHalfAngle and verticalHalfAngle (in degrees).
Construct a rotation with the given values, defaults to (0, 0, 0).
None
Rotation.New(Quaternion q)
Rotation
Construct a rotation using the given Quaternion.
None
Rotation.New(Vector3 forward, Vector3 up)
Rotation
Construct a rotation that will rotate Vector3.FORWARD to point in the direction of the given forward vector, with the up vector as a reference. Returns (0, 0, 0) if forward and up point in the exact same (or opposite) direction, or if one of them is of length 0.
None
Rotation.New(Rotation r)
Rotation
Copies the given Rotation.
None
Rotation.ZERO
Rotation
Constant Rotation of (0, 0, 0).
None
Operator
Return Type
Description
Tags
Rotation + Rotation
Rotation
Add two rotations together.
None
Rotation - Rotation
Rotation
Subtract a rotation.
None
Rotation * Number
Rotation
Returns the scaled rotation.
None
-Rotation
Rotation
Returns the inverse rotation.
None
Rotation * Vector3
Vector3
Rotates the right-side vector and returns the result.
Script is a CoreObject representing a script. While not technically a property, a script can access itself using the script variable.
Property
Return Type
Description
Tags
context
table
Returns the table containing any non-local variables and functions created by the script. This can be used to call (or overwrite!) functions on another script.
SmartAudio objects are SmartObjects that wrap sound files. Similar to Audio objects, they have many of the same properties and functions.
Function
Return Type
Description
Tags
Play()
None
Begins sound playback.
Dynamic
Stop()
None
Stops sound playback.
Dynamic
FadeIn(Number time)
None
Starts playing and fades in the sound over the given time.
Dynamic
FadeOut(Number time)
None
Fades the sound out and stops over time seconds.
Dynamic
Property
Return Type
Description
Tags
isPlaying
bool
Returns if the sound is currently playing.
Read-Only
isSpatializationEnabled
bool
Default true. Set to false to play the sound without 3D positioning.
Read-Write, Dynamic
isAttenuationEnabled
bool
Default true, meaning sounds will fade with distance.
Read-Write, Dynamic
isOcclusionEnabled
bool
Default true. Changes attenuation if there is geometry between the player and the audio source.
Read-Write, Dynamic
isAutoPlayEnabled
bool
Default false. If set to true when placed in the editor (or included in a template), the sound will be automatically played when loaded.
Read-Only
isTransient (read/write )
bool
Default false. If set to true, the sound will automatically destroy itself after it finishes playing.
Read-Write, Dynamic
isAutoRepeatEnabled
bool
Loops when playback has finished. Some sounds are designed to automatically loop, this flag will force others that don't (can be useful for looping music.)
Read-Write, Dynamic
pitch
Number
Default 1. Multiplies the playback pitch of a sound. Note that some sounds have clamped pitch ranges (so 0.2-1 will work, above 1 might not.)
Read-Write, Dynamic
volume
Number
Default 1. Multiplies the playback volume of a sound. Note that values above 1 can distort sound, so if you're trying to balance sounds, experiment to see if scaling down works better than scaling up.
Read-Write, Dynamic
radius
Number
Default 0. If non-zero, will override default 3D spatial parameters of the sound. Radius is the distance away from the sound position that will be played at 100% volume.
Read-Write, Dynamic
falloff
Number
Default 0. If non-zero, will override default 3D spatial parameters of the sound. Falloff is the distance outside the radius over which the sound volume will gradually fall to zero.
Read-Write, Dynamic
fadeInTime
Number
Sets the fade in time for the audio. When the audio is played, it will start at zero volume, and fade in over this many seconds.
Read-Write, Dynamic
fadeOutTime
Number
Sets the fadeout time of the audio. When the audio is stopped, it will keep playing for this many seconds, as it fades out.
Read-Write, Dynamic
startTime
Number
The start time of the audio track. Default is 0. Setting this to anything else means that the audio will skip ahead that many seconds when played.
SmartObject is a top-level container for some complex objects and inherits everything from CoreObject. Note that some properties, such as collision or visibility, may not be respected by a SmartObject.
Function
Return Type
Description
Tags
GetSmartProperties()
table
Returns a table containing the names and values of all smart properties on a SmartObject.
None
GetSmartProperty(string)
value, bool
Given a property name, returns the current value of that property on a SmartObject. Returns the value, which can be an Integer, Number, bool, string, Vector3, Rotator, Color, or nil if not found. Second return value is a bool, true if the property was found and false if not.
None
SetSmartProperty(string, value)
bool
Sets the value of an exposed property. Value can be of type Number, bool, string, Vector3, Rotation or Color, but must match the type of the property. Returns true if the property was set successfully and false if not.
Dynamic
Property
Return Type
Description
Tags
team
Integer
Assigns the SmartObject to a team. Value range from 0 to 4. 0 is neutral team.
Read-Write, Dynamic
isTeamColorUsed
bool
If true, and the SmartObject has been assigned to a valid team, players on that team will see one color, while other players will see another color. Requires a SmartObject that supports team colors.
SpotLight is a Light that shines in a specific direction from the location at which it is placed.
Property
Return Type
Description
Tags
hasNaturalFalloff
bool
The attenuation method of the light. When enabled, attenuationRadius is used. When disabled, falloffExponent is used. Also changes the interpretation of the intensity property, see intensity for details.
Read-Write, Dynamic
falloffExponent
Number
Controls the radial falloff of the light when hasNaturalFalloff is false. 2.0 is almost linear and very unrealistic and around 8.0 it looks reasonable. With large exponents, the light has contribution to only a small area of its influence radius but still costs the same as low exponents.
Read-Write, Dynamic
sourceRadius
Number
Radius of light source shape.
Read-Write, Dynamic
sourceLength
Number
Length of light source shape.
Read-Write, Dynamic
innerConeAngle
Number
The angle (in degrees) of the cone within which the projected light achieves full brightness.
Read-Write, Dynamic
outerConeAngle
Number
The outer angle (in degrees) of the cone of light emitted by this SpotLight.
StaticMesh is a CoreObject representing a static mesh.
Function
Return Type
Description
Tags
GetColor()
Color
Returns the color override previously set from script, or 0, 0, 0, 0 if no such color has been set.
None
SetColor(Color)
None
Overrides the color of all materials on the mesh, and replicates the new colors.
Dynamic
ResetColor()
None
Turns off the color override, if there is one.
Dynamic
Property
Return Type
Description
Tags
isSimulatingDebrisPhysics
bool
If true, physics will be enabled for the mesh.
Read-Write, Dynamic
team
Integer
Assigns the mesh to a team. Value range from 0 to 4. 0 is neutral team.
Read-Write, Dynamic
isTeamColorUsed
bool
If true, and the mesh has been assigned to a valid team, players on that team will see a blue mesh, while other players will see red. Requires a material that supports the color property.
Read-Write, Dynamic
isTeamCollisionEnabled
bool
If false, and the mesh has been assigned to a valid team, players on that team will not collide with the mesh.
Read-Write, Dynamic
isEnemyCollisionEnabled
bool
If false, and the mesh has been assigned to a valid team, players on other teams will not collide with the mesh.
Read-Write, Dynamic
isCameraCollisionEnabled
bool
If false, the mesh will not push against the camera. Useful for things like railings or transparent walls.
Task is a representation of a Lua thread. It could be a Script initialization, a repeating Tick() function from a Script, an EventListener invocation, or a Task spawned directly by a call to Task.Spawn().
Class Function
Return Type
Description
Tags
Task.Spawn(function taskFunction, [Number delay])
Task
Creates a new Task which will call taskFunction without blocking the current task. The optional delay parameter specifies how many seconds before the task scheduler should run the Task. By default, the scheduler will run the Task at the end of the current frame.
None
Task.GetCurrent()
Task
Returns the currently running Task.
None
Task.Wait([Number delay])
Number
Yields the current Task, resuming in delay seconds, or during the next frame if delay is not specified.
None
Function
Return Type
Description
Tags
Cancel()
None
Cancels the Task immediately. It will no longer be executed, regardless of the state it was in. If called on the currently executing Task, that Task will halt execution.
None
GetStatus()
TaskStatus
Returns the status of the Task. Possible values include: TaskStatus.UNINITIALIZED, TaskStatus.SCHEDULED, TaskStatus.RUNNING, TaskStatus.COMPLETED, TaskStatus.YIELDED, TaskStatus.FAILED, TaskStatus.CANCELED.
None
Property
Return Type
Description
Tags
id
Number
A unique identifier for the task.
Read-Only
repeatCount
Number
If set to a non-negative number, the Task will execute that many times. A negative number indicates the Task should repeat indefinitely (until otherwise canceled). With the default of 0, the Task will execute once. With a value of 1, the script will repeat once, meaning it will execute twice.
Read-Write
repeatInterval
Number
For repeating Tasks, the number of seconds to wait after the Task completes before running it again. If set to 0, the Task will wait until the next frame.
Transforms represent the position, rotation, and scale of objects in the game. They are immutable, but new Transforms can be created when you want to change an object's Transform.
A trigger is an invisible and non-colliding CoreObject which fires events when it interacts with another object (e.g. A Player walks into it):
Event
Return Type
Description
Tags
beginOverlapEvent
Event<Trigger trigger, Object other>
Fired when an object enters the Trigger volume. The first parameter is the Trigger itself. The second is the object overlapping the Trigger, which may be a CoreObject, a Player, or some other type. Call other:IsA() to check the type.
None
endOverlapEvent
Event<Trigger trigger, Object other>
Fired when an object exits the Trigger volume. Parameters the same as beginOverlapEvent.
None
interactedEvent
Event<Trigger trigger, Player>
Fired when a player uses the interaction on a trigger volume (F key). The first parameter is the Trigger itself and the second parameter is a Player.
None
Function
Return Type
Description
Tags
IsOverlapping(CoreObject)
bool
Returns true if given CoreObject overlaps with the Trigger.
None
IsOverlapping(Player)
bool
Returns true if given player overlaps with the Trigger.
None
GetOverlappingObjects()
Array<Object>
Returns a list of all objects that are currently overlapping with the Trigger.
None
Property
Return Type
Description
Tags
isInteractable
bool
Interactable Triggers expect Players to walk up and press the F key to activate them.
Read-Write, Dynamic
interactionLabel
string
The text players will see in their HUD when they come into range of interacting with this trigger.
Read-Write, Dynamic
team
Integer
Assigns the trigger to a team. Value range from 0 to 4. 0 is neutral team.
Read-Write, Dynamic
isTeamCollisionEnabled
bool
If false, and the Trigger has been assigned to a valid team, players on that team will not overlap or interact with the Trigger.
Read-Write, Dynamic
isEnemyCollisionEnabled
bool
If false, and the Trigger has been assigned to a valid team, players on enemy teams will not overlap or interact with the Trigger.
A Weapon is an Equipment that comes with built-in Abilities and fires Projectiles.
Event
Return Type
Description
Tags
targetImpactedEvent
Event<Weapon, ImpactData>
Fired when a Weapon interacts with something. E.g. a shot hits a wall. The ImpactData parameter contains information such as which object was hit, who owns the Weapon, which ability was involved in the interaction, etc.
Server-Only
projectileSpawnedEvent
Event<Weapon, Projectile>
Fired when a Weapon spawns a projectile.
None
Function
Return Type
Description
Tags
HasAmmo()
bool
Informs whether the Weapon is able to attack or not.
None
Attack(target)
None
Triggers the main ability of the Weapon. Optional target parameter can be a Vector3 world position, a Player, or a CoreObject.
None
Property
Return Type
Description
Tags
animationStance
string
When the Weapon is equipped this animation stance is applied to the Player.
Read-Only
attackCooldownDuration
Number
Interval between separate burst sequences.
Read-Only
multiShotCount
Integer
Number of Projectiles/Hitscans that will fire simultaneously inside the spread area each time the Weapon attacks. Does not affect the amount of ammo consumed per attack.
Read-Only
burstCount
Integer
Number of automatic activations of the Weapon that generally occur in quick succession.
Read-Only
shotsPerSecond
Number
Used in conjunction with burstCount to determine the interval between automatic weapon activations.
Read-Write
shouldBurstStopOnRelease
bool
If true, a burst sequence can be interrupted by the Player by releasing the action button. If false, the burst continues firing automatically until it completes or the Weapon runs out of ammo.
Read-Only
isHitscan
bool
If false, the Weapon will produce simulated Projectiles. If true, it will instead use instantaneous line traces to simulate shots.
Read-Only
range
Number
Max travel distance of the Projectile (isHitscan = False) or range of the line trace (isHitscan = True).
Read-Only
damage
Number
Damage applied to a Player when the weapon attack hits a player target. If set to zero, no damage is applied.
Read-Only
projectileTemplateId
string
Asset reference for the visual body of the Projectile, for non-hitscan Weapons.
Read-Only
muzzleFlashTemplateId
string
Asset reference for a Vfx to be attached to the muzzle point each time the Weapon attacks.
Read-Only
trailTemplateId
string
Asset reference for a trail Vfx to follow the trajectory of the shot.
Read-Only
beamTemplateId
string
Asset reference for a beam Vfx to be placed along the trajectory of the shot. Useful for hitscan Weapons or very fast Projectiles.
Read-Only
impactSurfaceTemplateId
string
Asset reference of a Vfx to be attached to the surface of any CoreObjects hit by the attack.
Read-Only
impactProjectileTemplateId
string
Asset reference of a Vfx to be spawned at the interaction point. It will be aligned with the trajectory. If the impacted object is a CoreObject, then the Vfx will attach to it as a child.
Read-Only
impactPlayerTemplateId
string
Asset reference of a Vfx to be spawned at the interaction point, if the impacted object is a player.
Read-Only
projectileSpeed
Number
Travel speed (cm/s) of Projectiles spawned by this weapon.
Read-Only
projectileLifeSpan
Number
Duration after which Projectiles are destroyed.
Read-Only
projectileGravity
Number
Gravity scale applied to spawned Projectiles.
Read-Only
projectileLength
Number
Length of the Projectile's capsule collision.
Read-Only
projectileRadius
Number
Radius of the Projectile's capsule collision
Read-Only
projectileDrag
Number
Drag on the Projectile.
Read-Only
projectileBounceCount
Integer
Number of times the Projectile will bounce before it's destroyed. Each bounce generates an interaction event.
Read-Only
projectilePierceCount
Integer
Number of objects that will be pierced by the Projectile before it's destroyed. Each pierce generates an interaction event.
Read-Only
maxAmmo
Integer
How much ammo the Weapon starts with and its max capacity. If set to -1 then the Weapon has infinite capacity and doesn't need to reload.
Read-Only
currentAmmo
Integer
Current amount of ammo stored in this Weapon.
Read-Write, Dynamic
ammoType
string
A unique identifier for the ammunition type.
Read-Only
isAmmoFinite
bool
Determines where the ammo comes from. If true, then ammo will be drawn from the Player's Resource inventory and reload will not be possible until the Player acquires more ammo somehow. If false, then the Weapon simply reloads to full and inventory Resources are ignored.
Read-Only
outOfAmmoSoundId
string
Asset reference for a sound effect to be played when the Weapon tries to activate, but is out of ammo.
Read-Only
reloadSoundId
string
Asset reference for a sound effect to be played when the Weapon reloads ammo.
Read-Only
spreadMin
Number
Smallest size in degrees for the Weapon's cone of probability space to fire Projectiles in.
Read-Only
spreadMax
Number
Largest size in degrees for the Weapon's cone of probability space to fire Projectiles in.
Read-Only
spreadAperture
Number
The surface size from which shots spawn. An aperture of zero means shots originate from a single point.
Read-Only
spreadDecreaseSpeed
Number
Speed at which the spread contracts back from its current value to the minimum cone size.
Read-Only
spreadIncreasePerShot
Number
Amount the spread increases each time the Weapon attacks.
Read-Only
spreadPenaltyPerShot
Number
Cumulative penalty to the spread size for successive attacks. Penalty cools off based on spreadDecreaseSpeed.
Some sets of related functionality are grouped within namespaces, which are similar to the types above, but cannot be instantiated. They are only ever accessed by calling functions within these namespaces.
Tick event, used for things you need to check continuously (e.g. main game loop), but be careful of putting too much logic here or you will cause performance issues. DeltaTime is the time difference (in ms) between this and the last tick.
None
time()
Number
Returns the time in seconds (floating point) since the game started on the server.
None
print(string)
string
Print a message to the event log. Access the Event Log from the "View" menu.
None
warn(string)
string
Similar to print(), but includes the script name and line number.
Draws a debug line. optionalParameters are: duration (Number) - if <= 0, draw for single frame, thickness (Number), color (Color).
None
CoreDebug.DrawBox(Vector3 center, Vector3 dimensions, [table optionalParameters])
None
Draws a debug box, with dimension specified as a vector. optionalParameters has same options as DrawLine, with addition of: rotation (Rotation) - rotation of the box
None
CoreDebug.DrawSphere(Vector3 center, radius, [table optionalParameters])
None
Draws a debug sphere.
None
CoreDebug Code Example
-- draw red line for 3 secondsCoreDebug.DrawLine(Vector3.New(0,0,0),Vector3.New(0,0,1000),{color=Color.RED,duration=3.0})-- draw box with dimension (100x200x300) for 10 seconds, rotated 45 degrees along Z axisCoreDebug.DrawBox(Vector3.New(1000,0,0),Vector3.New(100,200,300),{color=Color.BLUE,duration=10.0,rotation=Rotation.New(0,0,45)})-- draw cyan sphere with radius 50 for single frameCoreDebug.DrawSphere(Vector3.New(0,0,100),50,{color=Color.CYAN})
Splits the string s into substrings separated by delimiter. Optional parameters in the parameters table include: removeEmptyResults (bool): If true, empty strings will be removed from the results. Defaults to false. maxResults (integer): Limits the number of strings that will be returned. The last result will be any remaining unsplit portion of s. delimiters (string or Array<string>):Allows splitting on multiple delimiters. If both this and the delimiter parameter are specified, the combined list is used. If neither is specified, default is to split on any whitespace characters. Note that this function does not return a table, it returns multiple strings. For example: local myHello, myCore = CoreString.Split("Hello Core!") If a table is desired, wrap the call to Split() in curly braces, eg: local myTable = {CoreString.Split("Hello Core!")}
None
CoreString.Trim(string s, [...])
string
Trims whitespace from the start and end of s, returning the result. An optional list of strings may be provided to trim those strings from s instead of the default whitespace. For example, CoreString.Trim("(==((Hello!))==)", "(==(", ")==)") returns "(Hello!)".
User defined events can be specified using the Events namespace. The Events namespace uses the following class functions:
Class Function
Return Type
Description
Tags
Events.Connect(string eventName, function eventListener, [...])
EventListener
Registers the given function to the event name which will be called every time the event is fired using Broadcast. Returns an EventListener which can be used to disconnect from the event or check if the event is still connected. Accepts any number of additional arguments after the listener function, those arguments will be provided after the event's own parameters.
None
Events.ConnectForPlayer(string eventName, function eventListener, [...])
EventListener
Registers the given function to the event name which will be called every time the event is fired using BroadcastToServer. The first parameter the function receives will be the Player that fired the event. Returns an EventListener which can be used to disconnect from the event or check if the event is still connected. Accepts any number of additional arguments after the listener function, those arguments will be provided after the event's own parameters.
None
Events.Broadcast(string eventName, [...])
string
Broadcasts the given event and fires all listeners attached to the given event name if any exists. Parameters after event name specifies the arguments passed to the listener. Any number of arguments can be passed to the listener function. The events are not networked and can fire events defined in the same context.
Broadcasts the given event to all clients over the network and fires all listeners attached to the given event name if any exists. Parameters after event name specify the arguments passed to the listener on the client. The function returns a result code and a message. Possible result codes can be found below. This is a networked event. The maximum size a networked event can send is 128bytes and all networked events are subjected to a rate limit of 10 events per second.
Broadcasts the given event to a specific client over the network and fires all listeners attached to the given event name if any exists on that client. The first parameter specifies the Player to which the event will be sent. The parameters after event name specify the arguments passed to the listener on the client. The function returns a result code and a message. Possible result codes can be found below. This is a networked event. The maximum size a networked event can send is 128bytes and all networked events are subjected to a rate limit of 10 events per second.
Server-Only
Events.BroadcastToServer(string eventName, [...])
<BroadcastEventResultCode, string errorMessage>
Broadcasts the given event to the server over the network and fires all listeners attached to the given event name if any exists on the server. The parameters after event name specify the arguments passed to the listener on the server. The function returns a result code and a message. Possible result codes can be found below. This is a networked event. The maximum size a networked event can send is 128bytes and all networked events are subjected to a rate limit of 10 events per second.
Game is a collection of functions and events related to players in the game, rounds of a game, and team scoring.
Class Event
Return Type
Description
Tags
Game.playerJoinedEvent
Event<Player>
Fired when a player has joined the game and their character is ready.
None
Game.playerLeftEvent
Event<Player>
Fired when a player has disconnected from the game or their character has been destroyed.
None
Game.roundStartEvent
Event
Fired when StartRound is called on game.
None
Game.roundEndEvent
Event
Fired when EndRound is called on game.
None
Game.teamScoreChangedEvent
Event<Integer team>
Fired whenever any team's score changes. This is fired once per team who's score changes.
None
Class Function
Return Type
Description
Tags
Game.GetLocalPlayer()
Player
Returns the local player.
Client-Only
Game.GetPlayers([table parameters])
Array<Player>
Returns a table containing the players currently in the game. An optional table may be provided containing parameters to filter the list of players returned: ignoreDead(boolean), ignoreLiving(boolean), ignoreTeams(Integer or table of Integer), includeTeams(Integer or table of Integer), ignorePlayers(Player or table of Player), E.g.: Game.GetPlayers({ignoreDead = true, ignorePlayers = Game.GetLocalPlayer()}).
Returns the Player that is nearest to the given position. An optional table may be provided containing parameters to filter the list of players considered. This supports the same list of parameters as GetPlayers().
None
Game.FindPlayersInCylinder(Vector3 position, Number radius, [table parameters])
Array<Player>
Returns a table with all Players that are in the given area. Position's z is ignored with the cylindrical area always upright. An optional table may be provided containing parameters to filter the list of players considered. This supports the same list of parameters as GetPlayers().
None
Game.FindPlayersInSphere(Vector3 position, Number radius, [table parameters])
Array<Player>
Returns a table with all Players that are in the given spherical area. An optional table may be provided containing parameters to filter the list of players considered. This supports the same list of parameters as GetPlayers().
None
Game.StartRound()
None
Fire all events attached to roundStartEvent.
Server-Only
Game.EndRound()
None
Fire all events attached to roundEndEvent.
Server-Only
Game.GetTeamScore(Integer team)
Integer
Returns the current score for the specified team. Only teams 0 - 4 are valid.
The Storage namespace contains a set of functions for handling persistent storage of data. To use the Storage API, you must place a Game Settings object in your game and check the Enable Player Storage property on it.
Class Function
Return Type
Description
Tags
Storage.GetPlayerData(Player player)
table
Returns the player data associated with player. This returns a copy of the data that has already been retrieved for the player, so calling this function does not incur any additional network cost. Changes to the data in the returned table will not be persisted without calling Storage.SetPlayerData().
Server-Only
Storage.SetPlayerData(Player player, table data)
StorageResultCode, string
Updates the data associated with player. Returns a result code and an error message. See below for possible result codes and supported data types. Player data is limited to 16KB per player. Possible result codes: StorageResultCode.SUCCESS StorageResultCode.FAILURE StorageResultCode.STORAGE_DISABLED StorageResultCode.EXCEEDED_SIZE_LIMIT.
The UI namespace contains a set of class functions allowing you to get information about a Player's display and push information to their HUD. Most functions require the script to be inside a ClientContext and execute for the local Player.
Shows a quick text on screen that tracks its position relative to a world position. The last parameter is an optional table containing additional parameters: duration (Number) - How long the text should remain on the screen. Default duration is 0.5 seconds; color (Color) - The color of the Text. Default is white; isBig (boolean) - When true, larger text is used.
Client-Only
UI.ShowDamageDirection(Vector3 worldPosition)
None
Local player sees an arrow pointing towards some damage source. Lasts for 5 seconds.
Client-Only
UI.ShowDamageDirection(CoreObject source)
None
Local player sees an arrow pointing towards some CoreObject. Multiple calls with the same CoreObject reuse the same UI indicator, but refreshes its duration.
Client-Only
UI.ShowDamageDirection(Player source)
None
Local player sees an arrow pointing towards some other Player. Multiple calls with the same Player reuse the same UI indicator, but refreshes its duration. The arrow points to where the source was at the moment ShowDamageDirection is called and does not track the source Player's movements.
Client-Only
UI.GetCursorPosition()
Vector2
Returns a Vector2 with the x, y coordinates of the mouse cursor on the screen. Only gives results from a client context. May return nil if the cursor position cannot be determined.
Client-Only
UI.GetScreenPosition(Vector3 worldPosition)
Vector2
Calculates the location that worldPosition appears on the screen. Returns a Vector2 with the x, y coordinates, or nil if worldPosition is behind the camera. Only gives results from a client context.
Client-Only
UI.GetScreenSize()
Vector2
Returns a Vector2 with the size of the Player's screen in the x, y coordinates. Only gives results from a client context. May return nil if the screen size cannot be determined.
Client-Only
UI.PrintToScreen(string message, [Color])
None
Draws a message on the corner of the screen. Second optional Color parameter can change the color from the default white.
Client-Only
UI.IsCursorVisible()
bool
Returns whether the cursor is visible.
Client-Only
UI.SetCursorVisible(bool isVisible)
None
Sets whether the cursor is visible.
Client-Only
UI.IsCursorLockedToViewport()
bool
Returns whether to lock cursor in viewport.
Client-Only
UI.SetCursorLockedToViewport(bool isLocked)
None
Sets whether to lock cursor in viewport.
Client-Only
UI.CanCursorInteractWithUI()
bool
Returns whether the cursor can interact with UI elements like buttons.
Client-Only
UI.SetCanCursorInteractWithUI(bool)
None
Sets whether the cursor can interact with UI elements like buttons.
Client-Only
UI.IsReticleVisible()
bool
Check if reticle is visible.
Client-Only
UI.SetReticleVisible(bool show)
None
Shows or hides the reticle for the Player.
Client-Only
UI.GetCursorHitResult()
HitResult
Return hit result from local client's view in direction of the Projected cursor position. Meant for client-side use only, for Ability cast, please use ability:GetTargetData():GetHitPosition(), which would contain cursor hit position at time of cast, when in top-down camera mode.
Return intersection from local client's camera direction to given plane, specified by point on plane and optionally its normal. Meant for client-side use only. Example usage: local hitPos = UI.GetCursorPlaneIntersection(Vector3.New(0, 0, 0)).
Spawns an instance of an asset into the world. Optional parameters can specify a parent for the spawned object. Supported parameters include: parent (CoreObject) If provided, the spawned asset will be a child of this parent, and any Transform parameters are relative to the parent's Transform; position (Vector3): Position of the spawned object; rotation (Rotation or Quaternion): Rotation of the spawned object; scale (Vector3): Scale of the spawned object.
Traces a ray from rayStart to rayEnd, returning a HitResult with data about the impact point and object. Returns nil if no intersection is found. Optional parameters can be provided to control the results of the Raycast: ignoreTeams (Integer or Array<Integer>): Don't return any players belonging to the team or teams listed; ignorePlayers (Player, Array<Player>, or boolean): Ignore any of the players listed. If true, ignore all players.
For security reasons, various built-in Lua functions have been restricted or removed entirely. The available functions are listed below. Note that Lua's built-in trigonometric functions use radians, while other functions in Core uses degrees. See the reference manual for more information on what they do.
MUIDs are internal identifiers for objects and assets within your game. They are guaranteed to be unique within the game and likely to be unique globally. You can copy a MUID to the clipboard automatically by right-clicking assets in the Asset Manifest or placed objects in the Hierarchy. The MUID will look something like this:
8D4B561900000092:Rabbit
The important part is the 16 digits at the start. The colon and everything after it are optional and are there to make it easier to read. Some Lua functions use MUIDs, for example FindObjectById and SpawnAsset. When used in a script, it needs to be surrounded by quotes to make it a string. For example: