local m_state = "wait" local mission_time = nil --set this in the init(e) local prompt1 = "" --i set this inside the script so i can get the time later. --this is the variable used to determine if task has been completed or not mission_complete = 0 --so for collecting an object simply add 'mission_complete = 1' after player presses E in it's script. --if you simply want the player to reach a winzone then you likely won't need to worry as the level will end automatically --set the timer by the zone name (1 = 1s) --or in the part after checking for mission_time = nil function mission_timer_init_name(e,name) mission_time = tonumber(name)*1000 if mission_time == nil then mission_time = 3000000 --set timer here or in zone name end m_state = "wait" end function mission_timer_main(e) if m_state == "wait" then if GetPlayerInZone(e) == 1 then if prompt1 == "" then --change prompt shown while in zone here prompt1 = "Once You leave this zone you have "..round(mission_time/1000,1).." seconds to complete your mission" end Prompt(prompt1) entered_zone = 1 StartTimer(e) elseif entered_zone == 1 then m_state = "started" end elseif m_state == "started" then if GetTimer(e) < mission_time then --exchange Prompt here with Text or TextCenterOnX to show text in different place on screen --Prompt("You have "..round((mission_time/1000)-(GetTimer(e)/1000),1).." seconds remaining") TextCenterOnX(50,3,3,"You have "..round((mission_time/1000)-(GetTimer(e)/1000),1).." seconds remaining") --check for meeting requirement not to die here if mission_complete == 1 then m_state = "completed" end else if g_PlayerHealth > 0 then PlaySoundIfSilent(e,0) --set lives to 0 before hurting player to end game or remove lives line to only remove 1 life SetPlayerLives(0) HurtPlayer(e,g_PlayerHealth) end end end end function mission_timer_exit(e) end function round(num, idp) local mult = 10^(idp or 0) return math.floor(num * mult + 0.5) / mult end