I don't know what is wrong with my script, help!

local status = game.ReplicatedStorage.Status
local maps = game.ReplicatedStorage.Maps:GetChildren()
while true do
	for i = 1,10 do
		status.Value = "Intermisson - "..10-i
		wait(1)
	end
	local rand = math.random(1, #maps)
	
	local map = maps[rand]:Clone()
	map.Parent = workspace
	
	status.Value = "We'll be playing"..map.Name
	wait(4)
	local players = game.Players:GetChildren()
	for i = 1,#players do
		if players[i].Character ~= nil then
			local spawnLocation = math.random(1,#workspace.Teleports:GetChildren())
			players[i].Character:MoveTo(workspace.Teleports:GetChildren()[spawnLocation].Position)
			players[i].Character.Parent = workspace.Ingame
		end
		local roundLength = 50
		local canWin = true
		
		if map:FindFirstChild("Obby")then
			map.EndPart.Touched:Connect(function(hit)
				if hit.Parent:FindFirstChild("Humanoid")then
					local canWin = false
					
					status.Value = hit.Parent.Name.." has won!"
				end
			end)
		end
	end
	repeat
	roundLength = roundLength -1
	status.Value = "Time Left: "..roundLength
	wait(1)
	until roundLength == 0 or canWin == false or #workspace.Ingame:GetChildren() == 0
	
	wait(3)
	map:Destroy()
end

2 comments

0

The number of elements within the maps array is zero.

0

Oh, Thanks.