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

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

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

✓ Accepted answer

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

1 comment

0

Thank you

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