so i have this tiebreaker system in place for my minigames so that if there are no players left and the game is still running ( to avoid an unbreakable loop ) it can bring them back, but for some reason calls this value as nil
Error:
Flood Escape - Server - RoundSystem:106
ServerScriptService.RoundSystem:107: attempt to call a nil value - Server - RoundSystem:107
Stack Begin - Studio
Script 'ServerScriptService.RoundSystem', Line 107 - Studio - RoundSystem:107
Stack End - Studio
script:
ServerStorage = game:GetService("ServerStorage")
ReplicatedStorage = game:GetService("ReplicatedStorage")
Players = game:GetService("Players")
teams = game:GetService("Teams")
DataStoreService = game:GetService("DataStoreService")
CashDataStore = DataStoreService:GetDataStore("cashDataStore")
Maps = ServerStorage:WaitForChild('Maps'):GetChildren()
RoundStatus = ReplicatedStorage:WaitForChild('RoundStatus')
GameStatus = ReplicatedStorage:WaitForChild("GameStatus")
local Survivors = {}
while wait() do
if #game.Players:GetPlayers() >= 2 then
local countdown = 10
for i = countdown, 0, -1 do
RoundStatus.Value = "Intermission: "
GameStatus.Value = i
wait(1)
end
ChosenMap = Maps[math.random(1, #Maps)]:Clone()
MapName = game.ReplicatedStorage.MapName.Value
MapName = ChosenMap.Name
Spawns = ChosenMap:FindFirstChild('Spawns'):GetChildren()
countdown = 3
for i = countdown, 1, -1 do
RoundStatus.Value = ChosenMap.Name.." has been chosen!"
GameStatus.Value = i + 5
wait(1)
end
countdown = 5
for i = countdown, 0, -1 do
ChosenMap.Parent = workspace
RoundStatus.Value = "Teleporting everyone..."
GameStatus.Value = i
wait(1)
end
local Players = game.Players:GetPlayers()
for _, Player in ipairs(game.Players:GetPlayers())do
if Player.Character and Player.Character:WaitForChild('Humanoid') then
RandomSpawn = Spawns[math.random(1, #Spawns)]
Player.Character.HumanoidRootPart.CFrame = RandomSpawn.CFrame
Player.TeamColor = BrickColor.new("Persimmon")
Player.Character.Humanoid.MaxHealth = 100
Player.Character.Humanoid.Health = 100
Player.Character.Humanoid.WalkSpeed = 16
Survivors[Player] = true
end
end
wait(1)
countdown = 999999999999999999999999999999999999999999999999999999999999999999
for i = countdown, 0, -1 do
RoundStatus.Value = "Game is currently in progress.."
local Survivor = game.Teams.Playing
if #Survivor:GetPlayers() == 1 then
for i,v in pairs(game.Teams["Playing"]:GetPlayers()) do
v.leaderstats.Cash.Value += 1
for _, Player in pairs(game.Players:GetChildren())do
if Player.Character and Player.Character:FindFirstChild('Humanoid') then
Player.Character.Humanoid.Health = 0
end
end
countdown = 3
for i = countdown, 1, -1 do
ChosenMap:Destroy()
RoundStatus.Value = "Round Over!"
GameStatus.Value = i + 5
local winner = game.ReplicatedStorage.Winner
winner.Value = v.Name
wait(1)
end
countdown = 5
for i = countdown, 0, -1 do
ChosenMap:Destroy()
RoundStatus.Value = v.Name.. " has won!"
GameStatus.Value = i
winner = game.ReplicatedStorage.Winner
winner.Value = v.Name
wait(1)
end
wait(5)
winner.Value = "Nobody!"
end
break
end
while countdown > 0 and #Survivor:GetPlayers() == 0 do
ChosenMap:Destroy()
print(MapName)
ChosenMap = Maps:FindFirstChild(MapName):Clone()
ChosenMap.Parent = game.Workspace
for _, Player in ipairs(game.Players:GetPlayers())do
if Player.Character and Player.Character:WaitForChild('Humanoid') then
RandomSpawn = Spawns[math.random(1, #Spawns)]
Player.Character.HumanoidRootPart.CFrame = RandomSpawn.CFrame
Player.TeamColor = BrickColor.new("Persimmon")
Player.Character.Humanoid.MaxHealth = 100
Player.Character.Humanoid.Health = 100
Player.Character.Humanoid.WalkSpeed = 16
Survivors[Player] = true
end
end
end
wait(1)
end
else
local dots = "..."
repeat
for i = 1,3 do
RoundStatus.Value = "Waiting For Players"..string.sub(dots, 1, i)
wait(1)
end
until #game.Players:GetPlayers() >= 2
end
end
