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

Setting position for blocks but 10 spawn in the same spot?

I want to quickly set down some blocks in a couple of rows and everything works fine except for that the first block is actually a stack of 10 blocks.

i = 0
x  = 4
z = 0
while i < 98 do
	wait(.05)
	a = script.Parent.Emerald:Clone()
	a.Parent = game.Workspace
	if x == 40 then
		z = z + 4
		x = 0
	else
		a.Position = Vector3.new(x,2,z)
		x = x + 4
	end
	i = i + 1
end

1 answer

✓ Accepted answer

It's because you are cloning Emerald and putting it into workspace on every iteration even if you don't need to place it on that iteration.

maybe try

i = 0
x  = 4
z = 0
while i < 98 do
    wait(.05)
    if x == 40 then
        a = script.Parent.Emerald:Clone()
        a.Parent = game.Workspace
        a.Position = Vector3.new(x,2,z)
        z = z + 4
        x = 0
    else
        a = script.Parent.Emerald:Clone()
        a.Parent = game.Workspace
        a.Position = Vector3.new(x,2,z)
        x = x + 4
    end
    i = i + 1
end

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