So i have a game that has a timer and it ends once it hits 0:00. I want it to intermission for 15secs and teleport to the lobby, sometimes it bugs out at intermission: 0 or the timer is played in the lobby. BTW: THE TIMER GOING FAST IS ON PURPOSE, IT IS FOR THE VIDEO AND TESTING PURPOSES
Vid: https://youtu.be/TviFoH4R31k
Please help, I have been trying to fix this for a few days!
Server Script:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Lobbyspawn = game.Workspace.Lobby:WaitForChild("LobbySpawn")
local RoundSpawn1 = game.Workspace.SpawnLocations:WaitForChild("LobbyTP")
local ts = game:GetService("Teams")
local Loadedevent = ReplicatedStorage:WaitForChild("LoadedEvent")
local TimerEvent = ReplicatedStorage:WaitForChild("TimerEvent")
local Players = game:GetService("Players")
local checkpointsFolder = workspace:WaitForChild("Checkpoints")
local checkpoints = checkpointsFolder:WaitForChild("0")
local timer = script.Parent
local minutes = 1
local seconds = 0
local intermissionlength = 15
local intermissionEnded = false
local Roundended = false
Loadedevent.OnServerEvent:Connect(function(plr)
local function intermission()
for _, player in pairs (game.Players:GetChildren()) do
local char = player.Character
char.HumanoidRootPart.CFrame = Lobbyspawn.CFrame
repeat
for i = intermissionlength, 0, -1 do
wait(1)
print(i)
timer.Text = "Intermission: "..i
player.Team = game.Teams.Level0
if i == 0 then
Roundended = false
intermissionlength = 0
end
end
until intermissionlength == 0
end
end
local function Timer()
task.wait()
repeat
if seconds <= 0 then
minutes = minutes - 1
seconds = 59
else
seconds = seconds - 1
end
task.wait()
if seconds <= 9 then
timer.Text = tostring(minutes)..":0"..tostring(seconds)
else
timer.Text = tostring(minutes)..":"..tostring(seconds)
end
until minutes <= 0 and seconds <= 0
if minutes <= 0 and seconds <= 0 then
minutes = 1
seconds = 0
Roundended = true
if Roundended == true then
intermissionlength = 15
end
intermission()
end
end
Timer()
if intermissionlength == 0 then
for _, player in pairs (game.Players:GetChildren()) do
local char = player.Character
char.HumanoidRootPart.CFrame = RoundSpawn1.CFrame
end
Timer()
end
TimerEvent:FireClient(plr)
end)