How to make a timer that continues when the player leaves?

So I’m trying to make it so that you lose then you have to wait lets say 15 minutes but if you leave the timer has to continue instead off just leaving and joining, but all those tutorials make a new datastore but I already have 1 so please help me!

Heres my script:

gameOverFrame.Visible = true
				
				local gameOverTime = math.floor(chanceNumber / 500)
				
				if gameOverTime < 60 then
					while gameOverTime >= 0 do
						gameOverTimeText.Text = gameOverTime.." remaining"
						gameOverTime -= 1
						wait(1)
					end
				elseif gameOverTime / 60 < 60 then
					while gameOverTime >= 0 do
						local minutes = math.floor(gameOverTime / 60)
						local seconds = math.floor(gameOverTime - minutes * 60)
						gameOverTimeText.Text = minutes..":"..seconds.." remaining"
						gameOverTime -= 1
						wait(1)
					end
				elseif gameOverTime / 60 / 60 < 60 then
					while gameOverTime >= 0 do
						local hours = math.floor(gameOverTime / 60 / 60)
						local minutes = math.floor(gameOverTime - hours * 60)
						local seconds = math.floor(gameOverTime - minutes * 60 - hours * 60 * 60)
						gameOverTimeText.Text = hours..":"..minutes..":"..seconds.." remaining"
						gameOverTime -= 1
						wait(1)
					end
				end
				
				gameOverFrame.Visible = false
3 Likes

Instead of counting the time they’re away, count the time they leave to the time they rejoin

but how do I do that I have no idea

Datastores, os.time(), PlayerAdded, and PlayerRemoving

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.