Wait(10) not working. Please help

Hi, I have made a simple timer script from a youtube tutorial for my football (soccer) game.

When there is a goal, it teleports everyone, freezes them for 10 seconds.

So, obviously I want to stop the timer for 10 seconds, since my round are only 2:30 minutes.

I’ve added some comments on placed I’ve tried to add it. It just does not work there.
As you can see there is also a part that checks if a remote event fires, then changes waitfunction to true. This also did not freeze the timer.

Script:

while true do
	-- I've tried to add it here.
	minutesvalue.Value = minutes
	secondsvalue.Value = seconds
	workspace.RedPoint.OnServerEvent:Connect(function()
		waitfunction = true
	end)
	workspace.BluePoint.OnServerEvent:Connect(function()
		waitfunction = true
	end)
    -- Here too.
	repeat
    --Here too, did not work.
		if waitfunction == true then
			wait(10)
			waitfunction = false
		end
		if secondsvalue.Value <= 0 then
			minutesvalue.Value = minutesvalue.Value - 1
			secondsvalue.Value = 59
		else
			secondsvalue.Value = secondsvalue.Value - 1
		end
		wait(1)
		
		if secondsvalue.Value == 1 and minutesvalue.Value == 0 then
			if timeextra == false then
				local extratime = math.random(0, 5)

				extratimeevent:FireAllClients(extratime)
				wait(1)
				secondsvalue.Value = 0
				minutesvalue.Value = extratime
				timeextra = true
			end
		end
		
		if secondsvalue.Value <= 0 and minutesvalue.Value <= 0 then
			timeextra = false
			game.Workspace.Ref.RefWhistle:Play()
			anim:Play()
			game.Workspace.Ref.GameOver:Play()
			game.Workspace.Gameover:FireAllClients()

			local red = game.Workspace.RedPoints
			local blue = game.Workspace.BluePoints

			local redwin = red.Value > blue.Value
			local bluewin = blue.Value > red.Value
			local tie = blue.Value == red.Value

			if redwin == true then
				game.Workspace.RedPoints.Value = 0
				game.Workspace.BluePoints.Value = 0
				game.Workspace.RedWins:FireAllClients()
				
				for i, v in pairs(game.Teams.Red:GetPlayers()) do
					v:FindFirstChild("leaderstats"):FindFirstChild("Wins").Value = v:FindFirstChild("leaderstats"):FindFirstChild("Wins").Value + 1
				end
			end

			if bluewin == true then
				game.Workspace.BlueWins:FireAllClients()
				game.Workspace.RedPoints.Value = 0
				game.Workspace.BluePoints.Value = 0
				for i, v in pairs(game.Teams.Blue:GetPlayers()) do
					v:FindFirstChild("leaderstats"):FindFirstChild("Wins").Value = v:FindFirstChild("leaderstats"):FindFirstChild("Wins").Value + 1
				end
			end

			if tie == true then
				game.Workspace.RedPoints.Value = 0
				game.Workspace.BluePoints.Value = 0
				game.Workspace.TieGame:FireAllClients()
			end
			for i, v in pairs(game.Players:GetPlayers()) do
				v.Character.HumanoidRootPart.CFrame = workspace.LobbyPart.CFrame
				workspace.arePlayersInMap.Value = false
			end
			wait(60)
			
			game.Workspace.Ball.Position = Vector3.new(-2.5, 3.799, -4.5 )

			resetRed()
			resetBlue()
			workspace.arePlayersInMap.Value = true
			game.Workspace.Ref.RefWhistle:Play()
		end
	until secondsvalue.Value <= 0 and minutesvalue.Value <= 0
	task.wait()
end

It’s meant to wait if a remote event fires.

The event does fire, but the script does not work.

What exactly you have been adding to marked places? Was it just wait(10) or whole “if” statement?

What I have added was something around the lines of:

workspace.RedPoint2.OnServerEvent:Connect(function()
      wait(10)
end)

However, I have now tried with 2 events, since I never actually fired the server, but that also did not make it work.