Roblox Sword Fighting Game stuck on "Intermission"

I was trying to make it so that I had multiple maps in my game, but I accidentally made an error in the script and I don’t know how to fix it.

So, my game has rounds and every round the map could change, but then on the 2nd-3rd round it got stuck on “Intermission”


And comes up with this error.
image
image

I will show you what is in my game to make it easier.
image
So the problem is with the MainScript.
The “Stats” script is irrelivant to the problem.
I’ll show you whats inside of the “MainScript”

local ServerStorage = game:GetService("ServerStorage")
local CollectionService = game:GetService("CollectionService")
local Players = game:GetService("Players")

local mapsFolder = ServerStorage:WaitForChild("Maps")
local statusTag = ReplicatedStorage:WaitForChild("Status")

-- Constants
local GAME_LENGTH = 50
local REWARD = 25
local PLAYERS_REQUIRED = 2
local INTERMISSION_TIME = 10

-- Functions
local function onPlayerAdded(player)
	local function onCharacterAdded(character)
		local humanoid = character:WaitForChild("Humanoid")
		humanoid.Died:Connect(function()
			if CollectionService:HasTag(player, "Alive") then
				CollectionService:RemoveTag(player, "Alive")
			end
		end)
	end
	if player.Character then
		onCharacterAdded(player.Character)
	end
	player.CharacterAdded:Connect(onCharacterAdded)
end

Players.PlayerAdded:Connect(onPlayerAdded)

-- Main loop
while true do
	-- Waiting for players
	statusTag.Value = "Waiting for enough players"
	repeat
		task.wait(1)
	until
	#Players:GetPlayers() >= PLAYERS_REQUIRED

	-- Intermission
	for i = INTERMISSION_TIME, 0, -1 do
		statusTag.Value = "Intermission ["..i.."]"
		task.wait(1)
	end

	-- Choose a map
	function SelectMap()
		local Maps = {}

		for i, v in pairs(ServerStorage.Maps:GetChildren()) do
			if v:IsA("Model") then
				table.insert(Maps, v.Name)
			end
		end

		local randomMap = math.random(1, #Maps)
		local Map = Maps[randomMap]

		return Map
	end

	local ChosenMap = SelectMap()
	local Map = game.ServerStorage.Maps:FindFirstChild(ChosenMap)
	game.ServerStorage.Maps:FindFirstChild(ChosenMap):Clone().Parent = game.Workspace
	statusTag.Value = ChosenMap.. " was chosen"
	task.wait(3)

	-- Teleport players
	local activePlayers = Players:GetPlayers()
	local spawns = game.ServerStorage.Maps:FindFirstChild(ChosenMap)
	if not spawns then
		warn("You do not have 'SpawnPoints', fix pl0x")
	end
	spawns = spawns:GetChildren()

	for _, player in pairs(activePlayers) do
		local hrp = player.Character:FindFirstChild("HumanoidRootPart")
		if hrp then
			local chosenSpawn = spawns[math.random(#spawns)]
			hrp.CFrame = chosenSpawn.CFrame
			table.remove(spawns, table.find(spawns, chosenSpawn))

			-- Give them a sword
			local sword = ServerStorage.ClassicSword:Clone()
			sword.Parent = player.Backpack

			CollectionService:AddTag(player, "Alive")
		end
	end

	statusTag.Value = "Get ready to play!"
	task.wait(2)

	for i = GAME_LENGTH, 0, -1 do
		if #CollectionService:GetTagged("Alive") == 1 then
			-- only one player is alive
			local winner = CollectionService:GetTagged("Alive")[1]
			statusTag.Value = "The winner is "..winner.Name
			winner.leaderstats.Bucks.Value += REWARD
			break
		elseif #CollectionService:GetTagged("Alive") == 0 then
			-- nobody is alive
			statusTag.Value = "Nobody won!"
			break
		elseif i == 0 then
			-- timer ran out
			statusTag.Value = "Times up!"
			break
		end
		task.wait(1)
		statusTag.Value = "There are " .. i .. " seconds remaining, and " .. #CollectionService:GetTagged("Alive") .. " players left"
	end

	print("END OF GAME")

	-- Clean up
	for _, player in pairs(activePlayers) do
		if CollectionService:HasTag(player, "Alive") then
			CollectionService:RemoveTag(player, "Alive")
		end
		if player.Backpack:FindFirstChild("Sword") then
			player.Backpack.Sword:Destroy()
		end
		if player.Character:FindFirstChild("Sword") then
			player.Character.Sword:Destroy()
		end
		player:LoadCharacter()
	end

	game.ServerStorage.Maps:FindFirstChild(ChosenMap):Destroy()
	statusTag.Value = "Game over"
	task.wait(2)
end

Ive tried checking for capitals and looking at the error but I can’t seem to find the problem.
Thanks.
Sincerely, Jace.

1 Like

Interval Is Empty
" This error occurs when you pass the same integers of values that converge to the exact integers in the function. Or when your upper limit is lower than the lower limit . It creates an empty set of intervals. For example, if we execute math.random(5,1), this will throw an error because there is no interval from 5 to 1. (It should’ve been random(1,5)) "

Something is wrong with your Maps list, try debugging and seeing which maps it gathers.

Hey, could you check my newest post and help me there??

Need help aligning the crosshair - Help and Feedback / Scripting Support - DevForum | Roblox
This?
Sorry I don’t have any ideas that aren’t in the comments.

alvinblox and his tutorials… good old times anyways,

you made maps into an empty table, it is suppose to be

local Maps = mapsFolder:GetChildren()

No, sire. This one: Weird movements with the crouch animations - #4

for i, v in pairs(ServerStorage.Maps:GetChildren()) do
    if v:IsA("Model") then
        table.insert(Maps, v.Name)
    end
end

He has this below, to ensure that it only puts the models inside Maps and not anything else.

  • Also it needs to be a list of strings by the looks of things.

well now its just stuck on “Intermission” and then nothing else happeneds.
it also comes up with this error
image
image

1 Like

Yeah your trying to FindFirstChild(obj Model), either change the way the loop works or stick to what you had before and debug your map gathering.

why did alvin blox make things so hard, couldn’t he just have did

local  maps = mapsFolder:GetChildren()
local clonedMap = maps[math.random(1, #maps)]:Clone()
clonedMap.Parent = game.Workspace
1 Like

Can someone help me?? I am really eager to fix this problem. Sorry if I am selfish or smth