SO earlier I asked a question about how to fix something. But now, something else will not work. I was think about using another table but I do not know if it will work. Here's my script...
local status = game.ReplicatedStorage.status
local timer = game.ReplicatedStorage.timer
local plrsLeft = game.ReplicatedStorage.plrs
local gameTime = 70
local intermission = 20
local maps = game.ServerStorage.Maps
local id = game.ReplicatedStorage.ImageId
while true do
status.Value = "Waiting for more players."
plrsLeft.Value = "0/".. game.Players.NumPlayers
repeat wait(1) until game.Players.NumPlayers >= 1
for i = intermission,0,-1 do
status.Value = "Intermission"
id.Value = "http://www.roblox.com/asset/?id=4546507417"
local minutes = math.floor(i/60)
local seconds = math.floor(i%60)
timer.Value = (string.format("%i:%.2i", minutes, seconds))
wait(1)
local plrs = {}
for e, player in pairs(game.Players:GetPlayers()) do
if player then
table.insert(plrs,player)
if i == 0 then
status.Value = "Generating map."
wait(2)
local availableMaps = maps:GetChildren()
local chosenMap = availableMaps[math.random(1,#availableMaps)]
local clonedMap = chosenMap:Clone()
clonedMap.Parent = game.Workspace
wait(1)
status.Value = clonedMap.Name.." loaded, get ready."
wait(2)
local spawns = clonedMap:FindFirstChild("SpawnPoints")
local availableSpawns = spawns:GetChildren()
local character = player.Character
plrsLeft.Value = #plrs.."/".. game.Players.NumPlayers
character.HumanoidRootPart.CFrame = availableSpawns[1].CFrame
table.remove(availableSpawns,1)
for x = gameTime,0,-1 do
id.Value = "http://www.roblox.com/asset/?id=4546507994"
local minutes = math.floor(x/60)
local seconds = math.floor(x%60)
timer.Value = (string.format("%i:%.2i", minutes, seconds))
wait(1)
status.Value = "Game in progress."
character.Humanoid.Died:Connect(function()
table.remove(plrs,player)
print(player.Name.." has died/left the game.")
end)
if x <= 20 then
id.Value = "http://www.roblox.com/asset/?id=4546508680"
end
--// Pick a player to be monster ;)
local num = math.random(1,#plrs)
plrs[num].Character = game.ServerStorage.Telamon
game.ServerStorage.Telamon.Parent = workspace
wait(0.000000000000025)
workspace:FindFirstChild("Telamon").HumanoidRootPart.CFrame = clonedMap.MonsterSpawn.CFrame
table.remove(plrs, num)
if plrs[num] == 1 and #plrs == 0 then
status.Value = "Telamon wins."
plrs[num].leaderstats.Coins.Value = plrs[num].leaderstats.Coins.Value + 100
wait(1)
break
elseif x == 0 then
status.Value = "Time out."
wait(1)
break
elseif num == nil then -- This is where it stops working...
status.Value = "Telamon left."
wait(1)
break
end
player:LoadCharacter()
clonedMap:Destroy()
status.Value = "Gamer over."
plrsLeft.Value = "0/".. game.Players.NumPlayers
timer.Value = 0
wait(2)
end
player:LoadCharacter()
break
end
end
end
end
end

4 comments
It's line 72 btw
elseif num == 0 then
I know that this isn't related, but I think game.PLayers.Numplayers was deprecated; use #GetPlayers() instead.
^ He is correct, NumPlayers is deprecated. https://developer.roblox.com/en-us/api-reference/property/Players/NumPlayers