Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

What Instance.new does? does it appear a part or spawn something?

Asked by 6 years ago

I always tried to do something with the code called "Instance.new". Like i tried to do Instance.new Part but it did nothing it looks a little bit like Vector3.new

2 answers

Log in to vote
0
Answered by 6 years ago

Instance.new allows you to insert any object into whatever/wherever you want. For example, saying this will put a part into workspace:

Part = Instance.new(“Part”)
Part.Parent = workspace
0
Thx! Pizza64X 8 — 6y
0
Np cmgtotalyawesome 1418 — 6y
Ad
Log in to vote
0
Answered by
Aimarekin 345 Moderation Voter
6 years ago
Edited 6 years ago

Just as cmgtotalyawesome said, Instance.New creates any new object you would like.

You can simply do

Instance.new ("Part")

To create a part, but you may also do

Instance.new ("Part", game.Workspace.WeirdoModel)

To create the part in the model "WeirdoModel inside the "Workspace".

Maybe you want to make the part Anchored, for example. For that, we assign the part to a variable...

local partcreated = Instance.new ("Part", game.Workspace.WeirdoModel)

And this way, we'll can later modify the part through the variable partcreated.

local partcreated = Instance.new ("Part", game.Workspace.WeirdoModel)
partcreated.Anchored = true

-- You could change it's name, too.

partcreated.Name = MyNewPartIntoWeirdoModel

Too, you can use Instance.new to create other objects.

Instance.new ("Vector3Value", game.Workspace.WeirdoModel)

That would create a Vector3Value.

Hope I covered all!

Answer this question