GameEntity
set
Writes a value to the entity's statebag.
entity:set(key, value)
entity.set(key, value)
- key:
string - value:
any
Returns: boolean - If the state changed.
setr
Writes a replicated value to the entity's statebag. Client-set values are validated by the server.
entity:setr(key, value)
entity.setr(key, value)
- key:
string - value:
any
Returns: boolean - If the state changed.
sets
Writes a synced value to the entity's statebag. Client-set values are validated by the server.
Synced values are only replicated between the player and server, and cannot be set on non-player entities.
entity:sets(key, value)
entity.sets(key, value)
- key:
string - value:
any
Returns: boolean - If the state changed.
get
Returns a value from the entity's statebag.
entity:get(key)
entity.get(key)
- key:
string
Returns: unknown
has
Returns whether a key exists in the entity's statebag.
entity:has(key)
entity.has(key)
- key:
string
Returns: boolean
keys
Returns an array of all keys set on the entity's statebag.
entity:keys()
entity.keys()
Returns: string[]
setHandle
Updates the handle, netId, and statebag properties on an entity. Useful if re-using an entity instance, respawning an entity, changing the model, etc.
entity:setHandle(handle)
entity.setHandle(handle)
- handle:
number
getCoords
Gets the entity's current coordinates.
entity:getCoords()
entity.getCoords()
Returns: Vector3
setCoords
Sets the entity's coordinates to the specified position.
entity:setCoords(x, y, z, deadFlag, ragdollFlag, clearArea)
entity.setCoords()
- x:
number - y:
number - z:
number - deadFlag?:
boolean(Defaults to false) - ragdollFlag?:
boolean(Defaults to false) - clearArea?:
boolean(Defaults to false)
getModel
Gets the entity's current model hash.
entity:getModel()
entity.getModel()
Returns: number
getHeading
Gets the entity's current heading (or yaw) in degrees.
entity:getHeading()
entity.getHeading()
Returns: number
setHeading
Sets the entity's heading (or yaw) to the given value in degrees.
entity:setHeading(heading)
entity.setHeading(heading)
- heading:
number
getRoutingBucket
Gets the entity's current routing bucket.
entity:getRoutingBucket()
entity.getRoutingBucket()
Returns: number
setRoutingBucket
Sets the entity's routing bucket to the given id. Server only.
entity:setRoutingBucket(bucketId)
entity.setRoutingBucket(bucketId)
- bucketId:
number