How to add a wait to lua scripts.

  • megaduck
    29th Mar 2023 Member 0 Permalink

    I want to be able to add a wait to my lua scripts. For example:

     

    print("Hello")

    wait(5)

    print("goodbye")

     

    Is this possible?

  • RebMiami
    1st Apr 2023 Member 0 Permalink

    I'm pretty sure it's impossible to do parallel things like this in Lua, but you can achieve a similar effect like this:

     

    print("Hello!")

    local timeUntilGoodbye = 5 * 60 -- Seconds * frames per second

    event.register(event.tick, function()
        if timeUntilGoodbye == 0 then
            print("goodbye")
        end
        timeUntilGoodbye = timeUntilGoodbye - 1
    end)

  • z4dg9ssw135
    1st Apr 2023 Member 0 Permalink

    @RebMiami (View Post)

     idk lua but this somewhat reminds me of python , which gladly has wait library