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

How to make multiple [Repeat, Until] in the same script run together?

local part1 = script.Parent.Part1
local part2 = script.Parent.Part2
local part3 = script.Parent.Part3
local item = 0

repeat
	wait(5)
	local clone = part1:Clone()
	clone.Position = Vector3.new(0,0,0)
	clone.Parent = workspace
	item = item + 1
until item == 20

repeat
	wait(5)
	local clone = part2:Clone()
	clone.Position = Vector3.new(0,10,0)
	clone.Parent = workspace
	item = item + 1
until item == 20

repeat
	wait(5)
	local clone = part3:Clone()
	clone.Position = Vector3.new(0,5,0)
	clone.Parent = workspace
	item = item + 1
until item == 20

1 comment

1

Search up coroutines on developer.roblox.com

1 answer

✓ Accepted answer

Replace your script with the following:

local part1 = script.Parent.Part1
local part2 = script.Parent.Part2
local part3 = script.Parent.Part3
local item = 0

repeat
	wait(5)
	local clone = part1:Clone()
	clone.Position = Vector3.new(0,0,0)
	clone.Parent = workspace
	item = item + 1
until item == 20

repeat wait()
	wait(5)
	local clone = part2:Clone()
	clone.Position = Vector3.new(0,10,0)
	clone.Parent = workspace
	item = item + 1
	repeat wait()
		if item =~ 20 then
			wait(5)
			local clone = part1:Clone()
			clone.Position = Vector3.new(0,0,0)
			clone.Parent = workspace
			item = item + 1
			repeat wait()
				if item =~ 20 then
					wait(5)
					local clone = part3:Clone()
					clone.Position = Vector3.new(0,5,0)
					clone.Parent = workspace
					item = item + 1
				end
			until item == 20
		end
	until item == 20
until item == 20

I have set a lot of debounce values, which means that once it reaches it goal the same repeat will not play twice if it have done what it is supposed to do.

I hope that helps :D

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