Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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

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

2 comments

0

Thx!

0

Np

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!

This discussion is preserved as it was. New answers, comments, and votes are closed.