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

How to get Instance.new to apply to more than one brick?

So I don't know if this is correct but I made this so that once it is ran, it finds Plane in the workspace and it is supposed to take all of the parts named Brick in the model but I think it either only applies BlockMesh to one part rather than all of them. How could I get it to be applied to all the parts in the model that are named Brick?

local mesh = Instance.new("BlockMesh", game.Workspace.Plane.Brick)
print("Mesh Applied")

3 comments

0

idk, but i do know one way you can make your script shorter. don't say mesh.Parent = game.Workspace.Plane.Brick. say Instance.new("BlockMesh", game.Workspace.Plane.Brick)

0

Thank you!

0

Keep in mind, friend, that using the syntax Instance.new(className, Parent) is not at all recommended if you plan on customizing the object. Always set properties before parenting instances, because doing so on the DataModel is more expensive.

2 answers

✓ Accepted answer
for _, v in pairs(game.Workspace.Plane:GetChildren()) do
	if v.Name == "Brick" then
		local mesh = Instance.new("BlockMesh", v)
		print("Mesh Applied")
	end
end

What this does is that if it finds the part named "Brick" in your plane, it will apply the BlockMesh to every part named "Brick".

Try this

for _,v in pairs(game.Workspace.Plane:GetChildren()) do
	if v.Name == "Brick" then
local mesh = Instance.new("BlockMesh",v)
print("Mesh Applied")
	end
	end

edit: Accidently forgot to change something in this.

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