So, I was making a fighting game (FFS) and I had NO idea how to script, so I watched AlivinBlox script and I followed his steps. Somehow when I played the game ( w/ 2 players ) the state just froze to intermission. I had NO idea to fix it. Any suggestions or solutions? Heres the script:

local ReplicatedStorage = game:GetService("ReplicatedStorage")

local ServerStorage = game:GetService("ServerStorage")

local MapsFolder = ServerStorage:WaitForChild("Maps")

local Status = ReplicatedStorage:WaitForChild("Status")

local GameLength = 120

local reward = 100

local AmountOfPlayersRequired = 2

-- Game Loops

while true do
	
	Status.Value = "Waiting for players..."
	
	repeat wait(1) until game.Players.NumPlayers >= AmountOfPlayersRequired
	
	Status.Value = "Intermission"
	
	wait(1)
	
	local players = {}
	
	for i, players in pairs(game.Players:GetChildren()) do
		if players then
			table.insert(players,player) -- add each player to the table.
		end
	end
	
	wait(2)
	
	local AvailbleMaps = MapsFolder:GetChildren()
	
	local ChosenMap = AvailableMaps[math.random(1,#AvailableMaps)]
	
	Status.Value = ChosenMap.Name.." Chosen"
	
	local ClonedMap = ChosenMap:Clone()
	ClonedMap.Parent = workspace
	
	--TP Players to the chosen map.
	 local Spawnformap = ClonedMap:FindFirstChild("Spawnformap")
	
	if not Spawnformap then
		print("WHAT? R U KIDDING ME? NO SPAWNPOINTS!!!!1 PLEASE ADD Spawnformap FOR THAT MAP!!!!!!!")
	end
	
	local AvailableSpawnpoints = Spawnformap;GetChildren()
	--Please include more than 10 spawns in your map....
	
	for i, player in pairs(players) do
		if player then
			character = player.Character
			if character then
				--tp em
				character:FindFirstChild("HumanoidRootPart").CFrame = AvailableSpawnpoints[1].CFrame
				table.remove(AvailableSpawnpoints,1)
				
				--give sword or something, i guess.
				local Sword = ServerStorage.Sword:Clone()
				Sword.Parent = player.Backpack
				
				local GameTag = Instance.new("BoolValue")
				GameTag.Name = "GameTag"
				GameTag.Parent = player.Character
				
			else
				--no character
			if not player then
				table.remove(players,i)
			end
			end
		end
	end
end

Status.Value = "Get ready to brawl!"

wait(2)

for i = GameLength,0,-1 do
	for i, player in pairs(players) do
		if player then
			character = player.Character
			
			if not character then
				-- Left the game
			else
				if character:FindFirstChild("GameTag") then
					--they are alive!
					print(player.Name.."is still in-game!")
				else
					-- every1 is ded
					table.remove(players,x)
					print(player.Name.."has been removed!")
				end
			end
		else
		table.remove(players,x)
					print(player.Name.."has been removed!")
		end
	end
		
			Status.value = "There are "..i.." seconds remaining, and "..#players.." players left!"
			if #players == 1 then
				--last person standing!
				Status.value = "The winner is "..players[1].Name
				players[1].leaderstats.cash.value = players[1].leaderstats.cash.value + reward
				break
			elseif #players == 0 then
				Status.value = "Nobody won!"
			elseif i == 0 then
				Status.value = "Times up!"
				break
			end
			wait(1)
		end
		print("End of game")
		for i, player in pairs(game.Players:GetPlayers()) do
			character = player.Character
			if not character then
				--ignore...
			else
				if character:FindFirstChild("GameTag") then
					character.GameTag:Destroy()
				end
				
		if player.Backpack:FindFirstChild("Sword") then
			player.Backpack.Sword:Destroy()
		end
		
		if character:FindFirstChild("Sword") then
			character.Sword:Destroy()
		end
			end
		end
		player:LoadCharacter()
	end
end

ClonedMap:Destroy()

Status.Value = "Game Ended!"
wait(2)
end

2 comments

0

Please dont copy paste scripts. Doing that might make a lot of problems occur and you would never be able to fix them because you didn't make the script and you wouldn't undertand all the bits and pieces so please learn first in order to make a game successsful

0

Don't watch AlvinBlox. He is a terrible scripter.