Hello Developers! So I made a random map chooser which chooses a map when the count down imer is end and teleports the player to the choosen map.The problem is that the countdown timer replays again and again.
Can you help me?
This is my script:
local InGame = game.ReplicatedStorage.InGame
local Status = game.ReplicatedStorage.Status
local LobbySpawn = game.Workspace.Lobby.SpawnLocation
local Maps = game.ServerStorage.Maps:GetChildren()
local ChoosenMap = Maps[math.random(1, #Maps)]
local ChoosenSpawn = ChoosenMap.SpawnLocation
--- Teleport ---
InGame.Changed:Connect(function()
if InGame.Value == true then
wait(1)
for _, player in pairs(game.Players:GetChildren()) do
local character = player.Character
character.HumanoidRootPart.CFrame = ChoosenMap.SpawnLocation.CFrame
end
else
wait(1)
for _, player in pairs(game.Players:GetChildren()) do
local character = player.Character
character.HumanoidRootPart.CFrame = LobbySpawn.CFrame
end
end
end)
--- Intermission and game Timer ---
local function roundTimer()
while wait() do
for i = 30, 1, -1 do
InGame.Value = false
wait(1)
Status.Value = "Game starts in:"..i
end
for i = 100, 1, 1 do
InGame.Value = true
wait(1)
Status.Value = "Time left:"..i
end
end
end
spawn(roundTimer)