Hey all,
As of recently, I've been learning lua and lua for gmod.
In one of my recent things, I want to make a timer for every 5 seconds a piece of code will execute. To do this, I've been using the CurTime() + int "method". However this doesn't seem to work, I have a feeling it's something to do with the think function but I'm not too sure, if someone could help me out and point me out in the right direction that would be greatly appreciated! (Apologies for the double spacing, my keyboard's space bar is severely fucked)
Code:
function ENT:Think()
local delay = CurTime() + 5
if CurTime() == delay then
print("Test")
end
end
I also have a feeling to implement a variable to control how it reviews the if statement, but since it's think I'm not too sure. Also FYI There is no error printed to the console, it's just the line doesn't get executed.
You're adding 5 to the current CurTime and then checking if it's equal to the current CurTime, of course it's never gonna return true. Set a variable on the entity to CurTime + 5, then check inside your think if CurTime is greater than that. If it's greater than set the variable again.
Thanks for your reply. Will do so now!
Sorry, you need to Log In to post a reply to this thread.