How to make a script continue after a wait?

the title may be confusing but i want a script to continue right after a wait is called
here is what i mean:

local a = true
if a == true then
    wait(1000)
    print("1000 seconds has passed")
end
print("script finished")

i want the script instead of waiting 1000 seconds and then printing “script finished” i want it to print script finished immadietly and do the wait 1000 in the background. a bit difficult to explain but i hope you understand me

1 Like

You can utilise coroutines:

https://developer.roblox.com/en-us/api-reference/lua-docs/coroutine

3 Likes