Instance: Difference between revisions
Pizzaboxer (talk | contribs) (Created page with "{{CatUp|Tutorials}} __TOC__ == Introduction == An "Instance" refers to an Instance of an Object, hence the name. Instance is a very useful piece of script. It can be used...") |
mNo edit summary |
||
(One intermediate revision by one other user not shown) | |||
Line 3: | Line 3: | ||
== Introduction == | == Introduction == | ||
An "Instance" refers to an Instance of an Object, hence the name. Instance is a very useful piece of script. It can be used to create just about anything, and it is used often in | An "Instance" refers to an Instance of an Object, hence the name. Instance is a very useful piece of script. It can be used to create just about anything, and it is used often in Anaminus' Script Builder, and adding Messages via scripts in many places. | ||
It is different from: | It is different from: | ||
Line 61: | Line 61: | ||
[[Category:Scripting Tutorials]] | [[Category:Scripting Tutorials]] | ||
[[Category:Data Types]] |
Latest revision as of 11:36, 24 September 2021
Introduction
An "Instance" refers to an Instance of an Object, hence the name. Instance is a very useful piece of script. It can be used to create just about anything, and it is used often in Anaminus' Script Builder, and adding Messages via scripts in many places.
It is different from:
local o = game.Workspace.Object:Clone() o.Parent = game.Workspace
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.
Creating a Message
local msg = Instance.new("Message") msg.Parent = game.Workspace msg.Text = "Hello." wait(10) msg:Remove()
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
local p = Instance.new("Part") p.Parent = game.Workspace p.Name = "Brick" p.BrickColor = BrickColor.new(21) p.Anchored = true
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.
Creating an Explosion
local e = Instance.new("Explosion") e.Parent = game.Workspace
In the above script, "Instance.new" is creating a Explosion Object, with a variable name of "e".
Creating Sparkles
local g = Instance.new("Sparkles") --This creates the Sparkles g.Parent = game.Workspace.Player.Torso --Change Player to your Character's name and Torso to a part you want the sparkles to be in, so its basicly saying that the Sparkles will go in Player's torso.