I am trying to teleport the players when the timer is at 0, but when I start the game it works but when it gets to 1 it stops.
Script: local LobbyLocation = game.Workspace.Lobby.Position + Vector3.new(0,3,0)
local BlueGameLocation = game.Workspace.BlueTeamGame.Position + Vector3.new(0,3,0)
local RedGameLocation = game.Workspace.RedTeamGame.Position + Vector3.new(0,3,0)
local RedTeam = game.Teams[“Red Team”]
local BlueTeam = game.Teams[“Blue Team”]
local Players = game.Players.LocalPlayer
local ReplicatedStorage = game:GetService(‘ReplicatedStorage’)
local timeEvent = ReplicatedStorage:WaitForChild(‘TimeEvent’)
local function playGame()
local timeAmount = 20
local timerText = 'Game: ’
while timeAmount > 0 do
timeEvent:FireAllClients(timeAmount, timerText)
wait(1)
timeAmount -= 1
end
end
local function playIntermission()
local intermission = 10
local timerText = 'Intermission: ’
while intermission > 0 do
timeEvent:FireAllClients(intermission, timerText)
wait(1)
intermission -= 1
end
end
local function resetPlayers()
for _, plr in pairs(game.Players:GetChildren()) do
plr.Character.HumanoidRootPart.CFrame = CFrame.new(LobbyLocation)
end
end
local function blueTeamTeleportPlayers()
if Players.Teams == BlueTeam then
for _, plr in pairs(game.Players:GetChildren()) do
plr.Character.HumanoidRootPart.CFrame = CFrame.new(BlueGameLocation)
end
end
end
local function redTeamTeleportPlayers()
if Players.Teams == RedTeam then
for _, plr in pairs(game.Players:GetChildren()) do
plr.Character.HumanoidRootPart.CFrame = CFrame.new(RedGameLocation)
end
end
end
while true do
resetPlayers()
playIntermission()
redTeamTeleportPlayers()
blueTeamTeleportPlayers()
playGame()
end
Local Script: local label = script.Parent
local ReplicatedStorage = game:GetService(‘ReplicatedStorage’)
local timeEvent = ReplicatedStorage:WaitForChild(‘TimeEvent’)
timeEvent.OnClientEvent:Connect(function(timeAmount, timerText)
label.Text = timerText…timeAmount
end)