Creating a New object and Parenting (Scripting)

Instance.new(“Part”), this will create a part at the default brick color and the default size.

You can use “Instance.new()” for many many many things. If you go put to the “Insert” tab you can
see all the things you can make using it. Somethings you can make are hidden though.
When Instancing you need to set a parent, you would do that like this…
——————————–
i = Instance.new(“Part”)
i.Parent = workspace
——————————–
The parent is the place it will appear, so making it go into the workspace will make it appear in your virtual game. We’ll talk about parenting
more later on.
Now you’ve created your object you’re gonna want to edit it. Like the size and position, you would do that like this…
——————————–
i = Instance.new(“Part”)
i.Parent = workspace
i.Size = Vector3.new(2,2,2)
i.Position = Vector3.new(0,0,0)
——————————–

Instance.new(“Part”), this will create a part at the default brick color and the default size. You can use “Instance.new()” for many many many things. If you go put to the “Insert” tab you can see all the things you can make using it. Somethings you can make are hidden though.When Instancing you need to set a parent, you would do that like this…

i = Instance.new(“Part”)                                                                                                                                                                                                                                                                                                                                                                                                                                 i.Parent = workspace

The parent is the place it will appear, so making it go into the workspace will make it appear in your virtual game. We’ll talk about parenting more later on. Now you’ve created your object you’re gonna want to edit it. Like the size and position, you would do that like this…

i = Instance.new(“Part”)                                                                                                                                                                                                                                                                                                                                                                                                                                   i.Parent = workspace                                                                                                                                                                                                                                                                                                                                                                                                                                           i.Size = Vector3.new(2,2,2)                                                                                                                                                                                                                                                                                                                                                                                                                 i.Position = Vector3.new(0,0,0)

Parenting is the place an object appears in, E.g. like above I showed you how to parent a “Instance.new” object, here I will show you more about it.

Cloning is widely used, like the Instance.new(), it creates a new object. But you need to copy that object from somewhere first. You cannot create

a new obect using cloning. Here’s an example of a cloning script.

—————————-

c = game.Workspace.Part:Clone()

c.Parent = workspace

—————————–

I just cloned a part and put it in the workspace. It will have the same properties as the cloned one, e.g. if the part was blue the cloned one would be

blue.

You can basicly do the same as when you Instance.new() an object, but remember to always set the parent.

You can also parent something without it being cloned or making a new one. All you have to do is…

————————

game.Workspace.Part.Parent = game.Lighting

————————

This will make the game go into the lighting. The lighting is a great place to store scripts because they don’t run there, but you can also put

models, explosions and general things in there.

Also, Rememeber to set somethings parent you must do it in game. Orwise you can click and drag it around in the explorer menu (When in the

Roblox Studio).

Leave a comment