I am making a minigames game and every time i die when it select the next minigame it will just say that i won the game but i didn't (in the sword fights level need to be 2 players) if i don't reply i am not home,

Here is the link for my game if you want to try it yourself: --https://web.roblox.com/games/5634823302/Minigames

here is my main script:



if game.Workspace:FindFirstChild("Baseplate") then
	game.Workspace.Baseplate:Destroy()
end
wait(5)
local Seconds = game.ReplicatedStorage.Seconds
local Minutes = game.ReplicatedStorage.Minutes
local TimerValue = game.ReplicatedStorage.TimerText
local IsIntermision = false
while wait() do
	
	function Counter(minutes, seconds)
		Minutes.Value = minutes
		Seconds.Value = seconds
		wait(1)
		while wait() do
			if game.ReplicatedStorage.EndMinigame.Value == true then
				Minutes.Value = 0
				Seconds.Value = 0
				TimerValue.Value = "00:00"
				game.ReplicatedStorage.EndMinigame.Value = false
				break
			end
			if Seconds.Value > 0 then
				Seconds.Value = Seconds.Value -1
			elseif Seconds.Value == 0 and Minutes.Value > 0 then
				Seconds.Value = 59
				Minutes.Value = Minutes.Value -1
			elseif Seconds.Value == 0 and Minutes.Value == 0 then
				break
			end
			if IsIntermision == true then
				if Minutes.Value <=9 and Seconds.Value <= 9 then
					TimerValue.Value = "Intermision 0"..Minutes.Value..":0"..Seconds.Value
				elseif Minutes.Value <10 then
					TimerValue.Value = "Intermision 0"..Minutes.Value..":"..Seconds.Value
				elseif Seconds.Value <10 then
					TimerValue.Value = "Intermision "..Minutes.Value..":0"..Seconds.Value
				end
			elseif IsIntermision == false then
				if Minutes.Value <=9 and Seconds.Value <= 9 then
					TimerValue.Value = "0"..Minutes.Value..":0"..Seconds.Value
				elseif Minutes.Value <10 then
					TimerValue.Value = "0"..Minutes.Value..":"..Seconds.Value
				elseif Seconds.Value <10 then
					TimerValue.Value = Minutes.Value..":0"..Seconds.Value
					if game.ReplicatedStorage.EndMinigame.Value == true then
						Minutes.Value = 0
						Seconds.Value = 0
						TimerValue.Value = "00:00"
						game.ReplicatedStorage.EndMinigame.Value = false
						break
					end
					
				end
				
			end
			wait(1)
		end
		function TeleportPlayers(Position)
			for i,v in pairs(game.Players:GetPlayers()) do
				v.Character.HumanoidRootPart.CFrame = Position
			end
		end
	end
	function SelectMinigame()
		local Maps = game.ServerStorage.Maps
		local RandomMapIndex = math.random(1,#Maps:GetChildren())
		local ClonedMap = Maps:GetChildren()[RandomMapIndex]:Clone()
		ClonedMap.Name = "Map"
		ClonedMap.Parent = workspace
		local Message = Instance.new("Message")
		Message.Parent = workspace
		local Text = "Choosed Minigame: "..Maps:GetChildren()[RandomMapIndex].Name
		for i = 1,#Text,1 do
			Message.Text = string.sub(Text,1,i)
			wait(0.05)
		end
		wait(0.1)
		local Text2 = ClonedMap.Description.Value
		for i = 1,#Text2,1 do
			Message.Text = string.sub(Text2,1,i)
			wait(0.05)
		end
		wait(0.1)
		Message:Destroy()
		local RandomSpawnIndex = math.random(1,#ClonedMap.Spawns:GetChildren())
		local RandomSpawn = ClonedMap.Spawns:GetChildren()[RandomMapIndex]
		for i,player in pairs(game.Players:GetChildren())do
			if ClonedMap:FindFirstChild("Swords") then
				local RandomToolIndex = math.random(1,#ClonedMap.Swords:GetChildren())
				local RandomTool = ClonedMap.Swords:GetChildren()[RandomToolIndex]
				local ClonedTool = RandomTool:Clone()
				ClonedTool.Parent = player.Character
				ClonedTool.Name = "Tool"
			end
			player.Character.HumanoidRootPart.CFrame = RandomSpawn.CFrame
			player.Dead.Value = false
			wait()
			player.Dead.Value = false
		end
		Counter(ClonedMap.Minutes.Value,ClonedMap.Seconds.Value)
		print("Minigame Ended")
		local winers = {}
		for index, player in pairs(game.Players:GetChildren()) do
			if player.Dead.Value == false then
				player.leaderstats.Wins.Value = player.leaderstats.Wins.Value+1
				player.Points.Value = player.Points.Value+10
				table.insert(winers,#winers+1,tostring(player.Name))
			end
		end
		local M2 = Instance.new("Message")
		M2.Parent = workspace
		local WinersTable = table.unpack(winers,1,#winers)
		local T3 
		if #winers > 0 then
			T3 = "Winers:"..WinersTable
		else
			T3 = "No one has survived"
		end
		for i = 1,#T3,1 do
			M2.Text = string.sub(T3,1,i)
			wait(0.05)
		end
		for i,v in pairs(game.Players:GetChildren()) do
			if v.Character:FindFirstChild("Tool") then
				v.Character.Tool:Destroy()
			end
		end
		wait(0.5)
		for i = 1,#winers,1 do
			table.remove(winers,i)
		end
		TeleportPlayers(game.Workspace.SpawningRoom.SpawnLocation.CFrame)
		M2:Destroy()
		IsIntermision = true
	end
	if TimerValue.Value == "00:00" then
		if IsIntermision == false then
			IsIntermision = true
			print("IsNotIntermission")
		elseif IsIntermision == true then
			if game.Workspace:FindFirstChild("Map") then
				game.Workspace.Map:Destroy()
			end
			print("Intermision")
			wait(1)
			game.ReplicatedStorage.EndMinigame.Value = false
			Counter(0,10)
			IsIntermision = false
			SelectMinigame()
		end
		wait(1)
	end
end

3 comments

0

also i let only the flood escape map for testing i removed the other one

0

No ones going to answer a question with more than 60 lines

0

I know but the script is more than 60 lines