local template = world.FindFirstChild("CoinTemplate")
if template:
local coin = template.Clone()
coin.Position = new 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.
If true, this instance and all of its descendants cannot be selected in the editor.
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
Attaches a script to this instance by its file path. The path should be relative to the root assets directory, e.g. "Scripts/MyScript".
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 = new 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
Removes a script from this instance by its file path. The path should be relative to the root assets directory, e.g. "Scripts/MyScript".
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 = new Color3(1, 1, 0)
Gets the global bounding box that encapsulates all DynamicInstance children of this Instance.
Returns: The global bounding box of all DynamicInstance children, or null if there are none.
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.