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

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

Asked by
tjtorin 172
5 years ago

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

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

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

Ad

Answer this question