Timer not working

Hello. I’m trying to get a really simple timer to start working after my server starts up but it just…doesn’t work. I don’t really know what the problem is. I put this code in my lua/autorun/ folder and it’s not doing anything



timer.Create("TimerTest", 5, 0, function()
	print("Ellen Degeneres");
end)


From what I can tell, the syntax is fine. Try debugging to make sure the file is running in the first place.
Also, placing the file inside the autorun folder will make it shared, unless that’s what you want, place it inside client or server for it to be tied to that realm.

Have you tried
[lua]
timer.Simple(5, function()
…Code…
end)
[/lua]

Yea it is in the server folder, forgot to put that, my bad. When I remove the timer and just have it print something it works fine. I’ve tried doing it after InitPostEntity, I thought that might help. But still , no luck. I’m quite confused…

[editline]15th August 2015[/editline]

I have not. Can timer.Simple’s repeat infinitely? I’ve never used it and it doesn’t seem that they can.

That seems strange, and no timer.Simple cannot repeat infinitely unless you wrap it in a recursive function.

Change the name of the timer to something, perhaps a timer with that name already magically exists

I don’t recommend this, but for future reference, here’s how you make a recursive timer with timer.Simple


function TimerRecurse()

    -- Carry out your code here.

    timer.Simple( 5, TimerRecurse )

end

-- Then to start it, call the recursive function
TimerRecurse()



I just learned that timers only work when players are on the server. Sort of kills some of the functionality of what I was planning. Oh well, I’ll figure something out.

Thank you everyone for your help! Got it working when I put a bot on the server.