How to make when players teleport, and the timer sets again

Hello, I want to make a system that when a player teleports, the timer sets again. My game is has intermission, and game time. When there are 1 or 0 players, the player gets teleported back to the lobby. When the player gets teleported back, the timer doesn’t reset to the intermission timer. I would like some examples, or tutorials. Thank you.

PlayerCheckingScript(Credits to @Alvin_Blox, and @YT_Forceman):

local lobby = game.Workspace.LobbyTeleport
local inRound = game.ReplicatedStorage.InRound
local playersInPartRegion = {}




game.ReplicatedStorage.AddPlayerToTable.OnServerEvent:Connect(function(playerToAdd)
	if not table.find(playersInPartRegion, playerToAdd.Name) then
		table.insert(playersInPartRegion, playerToAdd.Name)
	end
end)

game.ReplicatedStorage.RemovePlayerFromTable.OnServerEvent:Connect(function(playerToRem)
	if table.find(playersInPartRegion, playerToRem.Name) then
		local count = 0
		for _, index in pairs(playersInPartRegion) do
			count = count + 1
			if index == playerToRem.Name then
				table.remove(playersInPartRegion, count)
				break
			end
		end
	end
end)


-- Now You Need to Check if The Players Near the Part / Touching the Part are More than 1.

while wait(5) do
	if #playersInPartRegion < 2 and #playersInPartRegion > 0 then
		for _, player in pairs(game.Players:GetChildren()) do
			if table.find(playersInPartRegion, player.Name) then
				local character = player.Character or player.CharacterAdded:Wait()
				local humanoidRootPart = character:WaitForChild("HumanoidRootPart")
				humanoidRootPart.Position = lobby.Position
			end
		end
	end
end

Intermission script(Credits to The DevKing):

local spawnsFolder = game.Workspace.Spawns
local spawnAreas = game.Workspace.Spawns:GetChildren()
local roundLength = 100
local intermissionTimer = 25

local inRound = game.ReplicatedStorage.InRound
local status = game.ReplicatedStorage.Status

local lobby = game.Workspace.LobbyTeleport
local gameAreaTeleport = spawnAreas[math.random(1, #spawnAreas)]


inRound.Changed:Connect(function()
	wait(1)
	gameAreaTeleport = spawnAreas[math.random(1, #spawnAreas)]
	if inRound.Value == true then
		for _, player in pairs(game.Players:GetChildren()) do
			local char = player.Character
			char:MoveTo(gameAreaTeleport.Position)		
		end
		
	else
		
		for _, player in pairs(game.Players:GetChildren()) do
			local char = player.Character
			char.HumanoidRootPart.CFrame = lobby.CFrame
		end
	end
end)


local function roundTimer()
	while wait() do
		for i = intermissionTimer, 1, -1 do
			inRound.Value = false
			wait(1)
			status.Value = "Intermission: ".. i .." seconds left!"
		end
		for i = roundLength, 1, -1 do
			inRound.Value = true
			wait(1)
			status.Value = "Game: ".. i .." seconds left!"
		end
			
		end
	end

spawn(roundTimer)
1 Like

have you tried setting the datatype of the instance source? the genotype energy is a sophisticated datastructure that needs a high velocity module that requires a variety of exothermic hydrotypes. after that you should be able to make the player teleport in the dynamic sourcetype.

2 Likes

I’m not asking for teleporting the players around. I’m asking for how to make a system that switches the timer to the intermission timer when the players are teleported.

1 Like

Set up a bool value that tracks wether a round is running or not, use the Changed Event to check for the value and start either the intermission timer or the round timer, depending on the value. I have the RoundTimer as a loop inside my intermission loop, so the intermission immediately starts whenever the round stops.

4 Likes