Round system failure

im using a round system that i had in place for an older game and i had to change up some things in it but now the code is broken for my new game. any help would be appreciated

code:

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')

local Survivors = {}

while true do
	if #game.Players:GetPlayers() >= 1 then
		--Intermission

		local Countdown = 5

		repeat wait(1)
			Countdown = Countdown - 1

			RoundStatus.Value = 'Intermission : '..Countdown
		until Countdown <= 0

		--Choose the map.

		RoundStatus.Value = 'Choosing map..'

		local ChosenMap = Maps[math.random(1, #Maps)]:Clone()
		local Spawns = ChosenMap:FindFirstChild('Spawns'):GetChildren()

		wait(3)

		ChosenMap.Parent = workspace
		RoundStatus.Value = 'Teleporting players..'

		wait(1)

		--teleport the players



		local Players = game.Players:GetPlayers()

		for _, Player in pairs(game.Players:GetPlayers())do
			if Player.Character and Player.Character:FindFirstChild('Humanoid') then
				local 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[Players] = true
			end
		end

		local Countdown = 60

		for i = Countdown, 0, -1 do
			RoundStatus.Value = "Game In Progress: "..i

			local Survivor = game.Teams.Playing
			if #Survivor:GetPlayers() == 1 then
				RoundStatus.Value = Survivors:GetPlayers().Name.. " has won!"
				for i, v in pairs(game.Teams["Playing"]:GetPlayers()) do
					v.leaderstats.Cash.Value = v.leaderstats.Cash.Value + 5
				end
				wait(5)
				break
			end

			wait(1)
		end

		--Kill the players

		for _, Player in pairs(game.Players:GetChildren())do
			if Player.Character and Player.Character:FindFirstChild('Humanoid') then
				Player.Character.Humanoid:TakeDamage(9999999999)
			end
		end

		ChosenMap:Destroy()

		RoundStatus.Value = 'Round over!'

		wait(1) -- little pause, make this as long as you want.
	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() >= 1
	end

end

error:

ServerScriptService.RoundSystem:64: attempt to call a nil value  -  Server  -  RoundSystem:64
Stack Begin  -  Studio
Script 'ServerScriptService.RoundSystem', Line 64  -  Studio  -  RoundSystem:64
Stack End  -  Studio

What’s at line 64 in your script? It appears to be attempting to call a nil value.

here try this!

Code
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')

local Survivors = {}

while true do
	if #game.Players:GetPlayers() >= 1 then
		--Intermission

		local Countdown = 5

		repeat wait(1)
			Countdown = Countdown - 1

			RoundStatus.Value = 'Intermission : '..Countdown
		until Countdown <= 0

		--Choose the map.

		RoundStatus.Value = 'Choosing map..'

		local ChosenMap = Maps[math.random(1, #Maps)]:Clone()
		local Spawns = ChosenMap:FindFirstChild('Spawns'):GetChildren()

		wait(3)

		ChosenMap.Parent = workspace
		RoundStatus.Value = 'Teleporting players..'

		wait(1)

		--teleport the players



		local Players = game.Players:GetPlayers()

		for _, Player in pairs(game.Players:GetPlayers())do
			if Player.Character and Player.Character:FindFirstChild('Humanoid') then
				local 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[Players] = true
			end
		end

		local Countdown = 60

		for i = Countdown, 0, -1 do
			RoundStatus.Value = "Game In Progress: "..i

			local Survivor = game.Teams.Playing
			if #Survivor:GetPlayers() == 1 then
				for i,v in pairs(game.Teams["Playing"]:GetPlayers()) do
					RoundStatus.Value = v.Name.. " has won!"
					v.leaderstats.Cash.Value = v.leaderstats.Cash.Value + 5
				end
				wait(5)
				break
			end

			wait(1)
		end

		--Kill the players

		for _, Player in pairs(game.Players:GetChildren())do
			if Player.Character and Player.Character:FindFirstChild('Humanoid') then
				Player.Character.Humanoid:TakeDamage(9999999999)
			end
		end

		ChosenMap:Destroy()

		RoundStatus.Value = 'Round over!'

		wait(1) -- little pause, make this as long as you want.
	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() >= 1
	end

end
1 Like