So basically, I was gonna remake my buggy "60 seconds" game. So basically, I went to test and noticed that the teleporting of players as well as my "allplayersDead" variable didn't work. The teleporting of players is a odd problem. I'm not getting any output errors, and the script continues to run after it doesn't teleport players. Help?
Also, on lines 31-36 it teleports players.
local players = game:GetService("Players"):GetPlayers()
local serverStorage = game:GetService("ServerStorage")
local maps = serverStorage:WaitForChild("Maps"):GetChildren()
local statusText = serverStorage:WaitForChild("statusText")
while wait(1) do
for intermissionTime = 10, 1, -1 do
statusText.Value = intermissionTime .. " until a new round starts!"
wait(1)
end
statusText.Value = "Choosing a map..."
wait(3)
repeat
chosenMap = maps[math.random(1, #maps)]
until chosenMap.Name ~= oldMap
statusText.Value = "The chosen map is " .. chosenMap.Name .. " by " .. chosenMap.Creator.Value .. "!"
local chosen = chosenMap:Clone()
chosen.Parent = workspace
wait(3)
for waitTime = 5, 1, -1 do
statusText.Value = "Teleporting players in... " .. waitTime
wait(1)
end
for i, v in pairs(players) do
local spawns = chosen:FindFirstChild("Spawns"):GetChildren()
v.won.Value = false
v.Character.Humanoid.WalkSpeed = 0
v.Character:MoveTo(spawns[i].Position)
end
wait(3)
statusText.Value = "All players have 60 seconds to finish. Go!"
for i, v in pairs(players) do
v.Character.Humanoid.WalkSpeed = 16
end
roundTime = 60
dead = 0
roundtimeReached = false
playerhasWon = false
allplayersDead = false
while wait(1) and roundTime > 0 do
for i, v in pairs(players) do
if v.Character.Humanoid.Health == 0 then
dead = dead + 1
if dead >= #players then
allplayersDead = true
elseif v.won.Value then
playerhasWon = true
elseif roundTime > 0 then
roundtimeReached = false
end
end
end
statusText.Value = "You have " .. roundTime .. " seconds left!"
roundTime = roundTime - 1
end
oldMap = chosenMap.Name
chosenMap:Destroy()
if playerhasWon then
wait(3)
statusText.Value = "A player has won!"
for i, v in pairs(players) do
if v.won.Value then
v.leaderstats.Points.Value = v.leaderstats.Points.Value + 10
end
end
elseif allplayersDead then
wait(3)
statusText.Value = "Everyone has died..."
elseif roundtimeReached then
wait(3)
statusText.Value = "The round time is up!"
end
end
