Ad
Still have questions? Join our Discord server and get real time help.
Log in to vote
0

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

Asked by 8 days 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
1
Answered by 8 days 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 38 — 8d
Ad

Answer this question