So, I need help with this, i’ve just started coding a few days ago and i’m making a simple gamemode (Don’t ask haha) to start off with , and i’m a slow learner I guess you could say. So, what I need help with is I have this timer in init.lua
local Time = 0
timer.Create(“Timer”, 0, 0, function( pl )
Time = Time + 1
CTime = CurTime(Time)
hook.Add( “PlayerSpawn”, “Timer”, Timer)
I suspect I did this wrong in some way, but it works the way I want it too nonetheless.
Next, I made an entity, and added this to the init.lua
for k, v in pairs(player.GetAll()) do
v:ChatPrint( ply:Nick() … " finished with a time of “…(string.ToMinutesSeconds(CTime))…” w00t!")
ply:Kill( ply )
ply:Spawn( ply )
And it works correctly when the player touches the entity, but, what I don’t know how to do is reset the timer back to 0 and start again when the player touches the entity and respawns. When I touch the entity again it just kept adding to the time it showed before. Can some one help me a n00b out please?
Thanks in advance!