Issues with delay()

Hi, I’m learning how to use this and I don’t understand what what’s wrong…

it’s supposed to be executed after 5 seconds or am I wrong?

function scheduledExecution()
   print('Hello world!')
end

delay(5000, scheduledExecution())

This isn’t milliseconds. You just put in 5000 seconds, which is why it won’t execute.

1 Like

I saw the formula from google and this is supposed to be so, what’s wrong?

image

As I just said, you put in 5000 seconds, it’s supposed to be in seconds, not ms.

Delay, unlike other languages that take milliseconds, takes seconds. Therefore, 5000 seconds is 5000 seconds, not 5 seconds. I’d also like to point out that you should switch to the new and improved task library. Example:

local function waitTwoSeconds()
    print("Waited 2 seconds!")
end

task.delay(2, waitTwoSeconds) -- Waits 2 seconds, then runs the function

my outout:

image

function scheduledExecution()
   print('Hello world!')
end

delay(5, scheduledExecution)

This should work if I’m not wrong.

1 Like

Oh I see! thanks guys now it’s solved! :smiley:

1 Like