I am trying to create a queue system for my game. However, the error on the title appears. Script is below
game.Players.PlayerAdded:Connect(function(player)
player.Chatted:Connect(function(message)
if player.UserId == game.CreatorId then
if message:sub(1, 7) == "/queue " then
local Gamemode = message:sub(8)
table.insert(queue, Gamemode)
print("Gamemode '" .. Gamemode .. "' has been added to the queue.")
end
end
end)
end)
local queue = {}
local ChosenMap = Maps[math.random(1, #Maps)]
local MapClone = ChosenMap:Clone()
wait(IntermissionTime.Value)
function selectRandomGamemode()
Gamemodes = {
["Gamemode1"] = 0.1,
["Gamemode2"] = 0.1,
["Gamemode3"] = 0.1
}
local Weight = 0
for _, Chance in pairs(Gamemodes) do
Weight += (Chance * 10)
end
local ranNumber = math.random(1, Weight)
Weight = 0
for Gamemode, Chance in pairs(Gamemodes) do
Weight += (Chance * 10)
if Weight >= ranNumber then
return
end
end
end
function getNextGamemode()
if next(queue) then
local Gamemode = table.remove(queue, 1)
print("The next gamemode from the queue is: " .. Gamemode.Name)
return Gamemode
else
return selectRandomGamemode()
end
end
Gamemode = getNextGamemode()
MapClone.Parent = game.Workspace.Map
MapClone:MakeJoints()
wait(3)
for i, v in pairs(game.Players:GetPlayers()) do
v.Character:FindFirstChild("HumanoidRootPart")
if v.Character.HumanoidRootPart == false then
return else
v.Character.HumanoidRootPart.CFrame = CFrame.new(Vector3.new(-430, 50, -430))
end
end
if Gamemode.Name == "Gamemode1" then
--insert game code here--
elseif Gamemode.Name == "Gamemode2" then
--insert game code here--
elseif Gamemode.Name == "Gamemode3" then
--insert game code here--
end
This isn’t all the code, but this is the important part
if Gamemode.Name == “Gamemode1” then
This line here is the part that breaks. I don’t know why or whats going on.