Instance (Table): Difference between revisions

From Legacy Roblox Wiki
Jump to navigationJump to search
>SoulStealer9875
No edit summary
>JulienDethurens
Undo revision 56764 by SoulStealer9875 (talk) That's incorrect. If the second argument is not specified, the parent will simply not be set.
 
(2 intermediate revisions by 2 users not shown)
Line 28: Line 28:
! Function                    !!  Description
! Function                    !!  Description
|-
|-
|  Instance.new('''val'''[, '''parent'''])  ||  Returns a new object of the class named by '''val'''. The '''parent''' argument is optional; if it is supplied the object will be parented to it, if not then the object's parent will be set to [[nil]]
|  Instance.new('''val'''[, '''parent'''])  ||  Returns a new object of the class named by '''val'''. The '''parent''' argument is optional; if it is supplied the object will be parented to it.
|-
|-
|}
|}

Latest revision as of 20:48, 17 April 2012

Instance

In ROBLOX, an Instance is an object in a ROBLOX game. ROBLOX Lua has a global table called Instance for changing how objects in the game behave. The Instance table offers several functions in order to create/manipulate ROBLOX created objects. It is best known for the Instance.new() function.

Creating Instances

Creating new objects is simpler than one would guess. You can find a list of object types (called classes) in the Class Reference. To create a new Instance, you use the Instance.new() function and pass one argument - a string that refers to what class you wish to make.

print(Instance.new("Part"))

Will result in:

Part

By default, objects created with Instance.new() retain their default properties (such as new bricks being 2 by 4 studs large). Because of this, the Parent property of created objects is nil and must be set for the object to be functional in the game.

You can pass a second argument to Instance.new to set the Parent of the object created:

Instance.new("Part", workspace)

Creates a Part and sets its parent to Workspace.

Functions

Function Description
Instance.new(val[, parent]) Returns a new object of the class named by val. The parent argument is optional; if it is supplied the object will be parented to it.