local template = world.FindFirstChild("CoinTemplate")
if template:
local coin = template.Clone()
coin.Position = Vector3(0, 5, 0)
coin.Parent = world
Instance
Inherits: TruWorldsObject
Instance is the base type for all TruWorlds game objects.
Instances form a hierarchical tree structure part of the DataModel, where each Instance can have one parent and multiple children. Instances can be created, destroyed, and replicated across the network. They also support events for changes in the hierarchy and lifecycle.
Properties
Whether this Instance or any of its descendants should be included when saving or copying via Clone()
The unique identifier for this Instance.
The name of this Instance.
The parent of this Instance in the hierarchy.
The sort index of this Instance among its siblings. If this Instance has no parent, this value is ignored.
Functions
Re-attaches an existing component ref (used by detach-undo to preserve identity).
Creates a deep clone of this Instance and all its descendants.
Returns: >A new Instance that is a deep clone of this Instance.
Removes this Instance, and all its descendants, from the DataModel, and locks its parent property.
local part = Part()
part.Parent = world
wait(5)
part.Destroy()
Schedules this Instance to be destroyed after the specified delay in seconds. This function will error if called multiple times.
- delaySeconds
Detaches a specific component by reference. Use this to remove a broken component, which has no live file to identify it by.
local door = world.FindFirstChild("Door")
if door:
door.Visible = false
Returns an array of the children of this Instance.
local folder = world.FindFirstChild("Coins")
if folder:
for child in folder.GetChildren():
child.Color = Color3(1, 1, 0)
Returns the path of the script component at , or an empty string if the script file no longer exists.
Determines if this Instance is a descendant of the specified ancestor Instance.
- ancestor
- The potential ancestor Instance.
Returns: True if this Instance is a descendant of the ancestor; otherwise, false.
Signals
Event fired when a child is added to this Instance.
Event fired when a child is removed from this Instance.
Event fired when a descendant is added to this Instance.
Event fired when a descendant is about to be removed from this Instance.
Event fired when this instance is destroyed.
Event fired when the parent of this Instance changes.
Event fired when this instance is removed from the DataModel.
Event fired when the sort order of this Instance changes.