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

help with making loop active while the rest of the script is still going?

Asked by 3 years ago

so, its like this

while true do -- this loop is still active when ("ThisIsATest is still active")  is printed
    wait()
    print("ThisIsATest")
end

print("ThisIsATest is still active")

1 answer

Log in to vote
2
Answered by 3 years ago

try doing spawn(function() or coroutine.wrap(function(), then put the loop inside. Do it like this:

spawn(function()
    while true do
        wait(1)
        print("ThisIsATest")
    end
end)

print("ThisIsATest is still active")

I added 1 to wait() so it will prevent too much stuff that you can't see the other print. You can also do the coroutine method:

coroutine.wrap(function()
    while true do
        wait(1)
        print("ThisIsATest")
    end
end)

print("ThisIsATest is still active")

Hope this helps!

0
tysm GameStealerKid 79 — 3y
Ad

Answer this question