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

How can you make a loop that stops when a condition is met then continues?

Asked by 6 years ago

I'm trying to make a loop that creates parts and stops when there's 20 parts, but then continues again when there is less than 20 parts in the game.

while wait(.1) do
    local model = game.Workspace.Model
    local children = model:GetChildren()
    local part = Instance.new("Part")
        part.Parent = workspace.Model
        part.Position = Vector3.new(10,10,10)
    print(#children)
    if #children >= 20 then

    end
end

1 answer

Log in to vote
1
Answered by
metryy 306 Moderation Voter
6 years ago

Make a while loop that runs while the amount of children in the workspace is below 20.

Example:

while #workspace:GetChildren()) < 20 do
    -- Create parts here
end
0
Thank you top500widowxd 23 — 6y
Ad

Answer this question