Model

self:set_parent

Shared

Attaches the model to another entity, or detaches it when no entity is given

Syntax

local status = self:set_parent(
    entity = nil
)

Parenting between server and client entities is restricted.

  • On the client — cannot be called on a server entity; raises an error.
  • On the server — a server entity can only be parented to another server (network-synced) entity.

Parameters

TypeNameDescription
entityentityParent entity instance, omit or pass nil to detach the instance

Returns

TypeNameDescription
boolstatustrue on successful execution, false if the reparent is invalid (target is itself or one of its descendants)

Examples

Parent one model to another
core.model.load("character", "models/character.glb")

local parent = core.model.create("character")
local child = core.model.create("character")

child:set_parent(parent)
Detach a model from its parent
core.model.load("character", "models/character.glb")

local parent = core.model.create("character")
local child = core.model.create("character")

child:set_parent(parent)
child:set_parent()

On this page