|
|
Line 1: |
Line 1: |
| {{CatUp|Scripting}} | | {{Disambig| |
| __TOC__
| | *[[Instance Table]] |
| | | *[[RBX.lua.Instance_(Object)|Instance Object]] |
| ==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|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.
| |
|
| |
| {{CodeExample}}
| |
| print(Instance.new("Part"))
| |
| </pre>
| |
| | |
| Will result in:
| |
| {{CodeExample}}
| |
| Part
| |
| </pre>
| |
| | |
| {{LeftNoticeStart}}
| |
| 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:
| |
| | |
| {{Example|
| |
| <pre>Instance.new("Part", workspace)</pre>
| |
| Creates a Part and sets its parent to Workspace.
| |
| }} | | }} |
| |}
| |
|
| |
| ==[[Functions]]==
| |
|
| |
|
| |
| {|border="1" cellspacing="5" style=" -webkit-border-radius: 4px; -moz-border-radius: 4px; height: 100%; background-color: #FFFFFF; border-top: dashed 2px #ff0000; border-left: dashed 2px #ff0000; border-bottom: dashed 2px #aa0000; border-right: dashed 2px #aa0000; margin: 6px; margin-right: 10px; margin-left: 10px; clear: none; padding: 2px;"
| |
| ! 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.
| |
| |-
| |
| | Instance.Lock('''val''', '''player''') || Sets a network enabled mutex for object val targeted at player.
| |
| |-
| |
| | Instance.Unlock('''val''') || Removes the network enabled mutex for object val.
| |
| |-
| |
| |}
| |