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

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

Asked by 3 years ago
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
Search up coroutines on developer.roblox.com DesertusX 435 — 3y

1 answer

Log in to vote
1
Answered by 3 years ago

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

Ad

Answer this question