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

Would anybody like to help me fix this Generation script?

Asked by 9 years ago
z = math.random(-24,24)
t = math.random(.009,.05)
NewPart = Instance.new("Part")

for i = 1, 900 do
    NewPart.Parent = Workspace
    NewPart.Size = Vector3.new(3.6, 1.2, 2)
    NewPart.Position = Vector3.new(22, 18.19, z)
    NewPart.BrickColor = BrickColor.new("Really black")

    for i = 1,146 do
        NewPart.CFrame = NewPart.CFrame* CFrame.new(0,.2,0)
            wait(t)
    end
    NewPart.remove()
        wait(5)
end

Every 5 seconds, it is supposed to create one block with a random Z vector as shown at the very top. It only creates one block, and then the script stops. I think it's the NewPart.remove() , but I'm not sure. What could I try instead of that?

1 answer

Log in to vote
2
Answered by
SanityMan 239 Moderation Voter
9 years ago

If you want to use the remove() function, it would be NewPart:remove()

local t = math.random(.009,.05)

for i = 1, 900 do
    local z = math.random(-24,24)
    NewPart = Instance.new("Part")
    NewPart.Parent = Workspace
    NewPart.Size = Vector3.new(3.6, 1.2, 2)
    NewPart.Position = Vector3.new(22, 18.19, z)
    NewPart.BrickColor = BrickColor.new("Really black")

    for i2 = 1,146 do
        NewPart.CFrame = NewPart.CFrame* CFrame.new(0,.2,0)
        wait(t)
    end

    NewPart.remove()
    wait(5)
end
0
Thank you! I must've accidentally done that, and then missed it while proof reading. Lightdrago 95 — 9y
0
Happy to help! SanityMan 239 — 9y
0
Oh, there's also another problem. It doesn't recalculate the random Z value. Could you help me with that as well? Lightdrago 95 — 9y
0
I have changed my post. It should now generate a new part with a new z value every time the first for loop scope runs. SanityMan 239 — 9y
0
Thanks, it does. Lightdrago 95 — 9y
Ad

Answer this question