GameMode and Match system stuck for days

So im trying to make a match with gamemode system and had been stuck a few days, i tried to get a little break and then come back to the script but im back to the start i just can’t figure out how to make it

I can code by myself i just need help with the algorithm but if the code its provided i would be happier

Thanks in advice

function SetGameMode(Mode,Teams,Match)
	local Goal
	if Mode == "PirateWar" then
		print("War")
		Goal = 25
		local Points1 = 0
		local Points2 = 0
		for i,v in pairs(Teams) do
			local Player = v[1]
			local Char = Player.Character
			local Humanoid = Char:WaitForChil("Humanoid")
			Humanoid.Died:Connect(function()
				if v[3] == "Phoenix" then
					Points2 = Points2 + 1
					if Points2 == Goal then
						if Match == "Match1" then
							ForceWin1 = true
						elseif Match == "Match2" then
							ForceWin2 = true
						end
					end
				elseif v[3] == "Griffin" then
					Points1 = Points1 + 1
					if Points1 == Goal then
						if Match == "Match1" then
							ForceWin1 = true
						elseif Match == "Match2" then
							ForceWin2 = true
						end
					end
				end
				print(Points1.." Phoenix")
				print(Points2.." Griffin")
			end)
		end
	elseif Mode == "Elimination" then
		print(Mode)
	elseif Mode == "IslandCapturing" then
		print(Mode)
	elseif Mode == "GetTheTreasure" then
		print(Mode)
	elseif Mode == "PoisonSurvival" then
		print(Mode)
	elseif Mode == "TheRaid" then
		print(Mode)
	else
		print(Mode.."Bug")
	end
end
function StartMatch(Teams,Match)
	local crew 
	if Match == "Match1" then
		crew = 1
		if waiting1 == false then
			waiting1 = true
		else
			return
		end
	elseif Match == "Match2" then
		crew = 2
		if waiting2 == false then
			waiting2 = true
		else
			return
		end
	end
	local Start = tick()
	local N = 30
	if #Teams >= 1 then
		while math.floor(Start - tick()) < 30 and N > 0 do
			N = N - 1
			for i, v in pairs(Teams) do
				UpdateMatch:FireClient(v[1],Teams,"Timer",N)
			end
			wait(1)
		end	
		if #Teams >= 1 then
			local Maps = {"Map1"}
			local Map = math.random(1,#Maps)
			local Current = Maps[Map]
			
			local GameModes = {"PirateWar"}--,"IslandCapturing","GetTheTreasure","Elimination","PoisonSurvival","TheRaid"--}
			local mode = math.random(1,#GameModes)
			local GameMode = GameModes[mode]
			
			local Spawner
			
			for i, v in pairs(Teams) do
				Par[Match.."On"].Value = true
				Par[Match.."On"].Loop.Value = false
				local Teams = game:GetService("Teams")
				local Player = v[1]
				local Char = Player.Character			
				Player.Team = Teams:FindFirstChild(v[3]..crew)
				UpdateMatch:FireClient(Player,Match1Players,true)
				
				Spawner = Player.CharacterAdded:Connect(function()
					wait(0.2)
					print("Respawn")
					local new = Player.CharacterAdded:Wait()
					SetChar(new,v,"Start")
					Char.HumanoidRootPart.CFrame = workspace:FindFirstChild(Current):FindFirstChild(v[3]).SpawnLocation.CFrame * CFrame.new(0,5,0)
				end)

				
				for x,y in ipairs(Char:GetChildren()) do
					if y:IsA("Accessory") then
						y.Handle.Transparency = 1 
					end
				end
				for x,y in ipairs(Char:GetChildren()) do
					if y:IsA("Shirt") or y:IsA("Pants") then
						y:Destroy()
					end
				end
				
				Char.HumanoidRootPart.CFrame = workspace:FindFirstChild(Current):FindFirstChild(v[3]).SpawnLocation.CFrame * CFrame.new(0,5,0)
				
				LoadClass(v)
				SetChar(Char,v,"Start")	
			end
			
			local Set = coroutine.create(SetGameMode)
			coroutine.resume(Set, GameMode, Teams, Match)
			print("Start")
			
			if Match == "Match1" then
				while ForceWin1 == false do
					wait(1)
				end
				ForceWin1 = false
			elseif Match == "Match2" then
				while ForceWin2 == false do
					wait(1)
				end
				ForceWin2 = false
			end			

			for i, v in pairs(Teams) do
				local Teams = game:GetService("Teams")
				local Player = v[1]
				local Char = Player.Character		
				Spawner:Disconnect()
				if Char:FindFirstChild("Humanoid") then
					Char:FindFirstChild("Humanoid"):UnequipTools()
				end
				for s,c in ipairs(v[1].Backpack:GetChildren())do
					c:Remove()
				end
				SetChar(Char,v,"Close")
				for s,c in ipairs(Char:GetChildren()) do
					if c:IsA("Tool") then
						c:Remove()
					end
				end

				for x,y in ipairs(Char:GetChildren()) do
					if y:IsA("Accessory") then
						y.Handle.Transparency = 0 
					end
				end
				Char = nil
				Player:LoadCharacter()
				
				wait(0.2)
				Player.CharacterAdded:Wait().HumanoidRootPart.CFrame = workspace:FindFirstChild("SpawnLocation").CFrame * CFrame.new(0,5,0)
				Par[Match.."On"].Value = false
				Player.Team = nil
			end
		end
	end
end
return Match

I don’t think anyone is going to be able to help you due to the lack of information.

  • What exactly is the issue?
  • What’s the expected functionality?

Was waiting for this response, but didn’t remember to include in the post so:

The Issue is pretty much the actual gamemode, the gamemode selection is okay and it just fire, the point is, the died function don’t work/ points are not being added. and i don’t have any idea on how to implement the end function and the respawn part since resetting break alot of things.

I Want a good system i wanted to make it work atleast maybe a bit optimized.

If you need more info i will gladly post the whole code and explain better and pls be specific in what information you need
Thanks in advice =)

Bump, anyone still able to help? tell me if you need more infos