|
|
(47 intermediate revisions by 15 users not shown) |
Line 1: |
Line 1: |
| == What is it? ==
| | #redirect [[RBX.lua.Instance (Object)]] |
| An "Instance" refers to an Instance of an Object, hence the name. Instance is one very useful piece of script. It can be used to create just about anything, and it is used often in [[Anaminus]]' Script Builder.
| |
| | |
| It is different from:
| |
| | |
| <pre>
| |
| local o = game.Workspace.Object:Clone()
| |
| o.Parent = game.Workspace
| |
| </pre>
| |
| | |
| Instance actually creates an Object from scratch, instead of copying from somewhere else.
| |
| In the next section, we will take a look at some examples.
| |
| | |
| == Examples ==
| |
| | |
| '''Creating a Message''':
| |
| | |
| <pre>
| |
| local msg = Instance.new("Message")
| |
| | |
| msg.Parent = game.Workspace
| |
| msg.Text = "Hello."
| |
| wait(10)
| |
| msg:Remove()
| |
| </pre>
| |
| | |
| In the above script, you see that "Instance.new" is creating a new object, a message, and making it's variable name "msg". The rest of the script then tells "msg" what to do.
| |
| | |
| | |
| '''Creating a Part''':
| |
| | |
| <pre>
| |
| local p = Instance.new("Part")
| |
| | |
| p.Parent = game.Workspace
| |
| p.Name = "Brick"
| |
| p.BrickColor = BrickColor.new(21)
| |
| </pre>
| |
| | |
| In the above script, "Instance.new" is creating a Part Object, with a variable name of "p", and again, the script tells it what it wants to do. This script is very useful indeed.
| |