local Players1 = {}
local Sniper = ""

local IntermissionGUI = game.ReplicatedStorage:WaitForChild("InfoValue")

local function RandomSniper()
	local Random = math.random(1,game.Players.NumPlayers)
  
	Sniper = Players1[Random] 
  
	print(Sniper)
  
	table.remove(Players1, Random)
  
	return true
end

local function CountDown()
  local Sound = Instance.new("Sound",game.Workspace)
    
		Sound.SoundId = "http://www.roblox.com/asset/?id=134641113"
    
	for i = 10,0,-1 do
		IntermissionGUI.Value = "Intermissio n: " .. tostring(i)
    
    Sound:Play()
		wait(1.5)
    Sound:Stop()
	end
  Sound:Remove()
end

local function PlayerToNumber()
	local Players = game.Players:GetPlayers()
  
  print("Activating")
  
	for i, v in pairs(Players) do
		table.insert(Players1,i,v.Name)
    
		print(Players1[i])
	end
  
	return true
end

local function SniperToPosition()
	print(RandomSniper())
  
	if RandomSniper() == true then
		local Sniper1 = game.Players:FindFirstChild(Sniper)
    
		print(Sniper1.Name)
    if Sniper1.Character.Torso ~= nil then
		Sniper1.Character.Torso.CFrame = game.Workspace.SpawningPart.CFrame
    
		local Gun = game.ServerStorage.Sniper:Clone()
    
		Gun.Parent = Sniper1.Backpack
      end
	end
end

local function PlayersToPosition()
	for _, v in pairs(Players1) do
		if v ~= Sniper then
			game.Players:FindFirstChild(v).Character.Torso.CFrame = game.Workspace.PlayerSpawningPart.CFrame + Vector3.new(0,2,math.random(-20,20))
      
			wait(3)
		end
	end
end 

local function RestartTheGame(Player)
  local humanoid = Player.Parent:FindFirstChild("Humanoid")
  
  if humanoid then
  	if Player.TeamColor == "Really blue" then
    	if humanoid.Health > 0 then 
      	if game.ReplicatedStorage.GameInProgress.Value then
					for _, v in pairs(game.Players:GetChildren()) do
          	local character = v.Character
            
            if character then
							local torso = character.Torso
              
              if torso then
              	torso.CFrame = game.Workspace.SpawningPart.CFrame + Vector3.new(math.random(-8, 8), 2, math.random(-8,8))
              end
            end end
					end
    			
					if game.ReplicatedStorage.NumberOfPlayers.Value > 1 then
						game.ReplicatedStorage.GameInProgress.Value = true
            
						CountDown()
						PlayerToNumber()
						RandomSniper()
						SniperToPosition()
						PlayersToPosition()
        	end		
				end
      end
    end
end

game.Players.PlayerRemoving:Connect(function(LeavingPlayer)
	local PlayerCount = game.ReplicatedStorage.NumberOfPlayers.Value
  
	PlayerCount = PlayerCount - 1
	for i,v in pairs(Players1) do
		if v == LeavingPlayer.Name then
			table.remove(Players1, i)
			if #Players1 < 2 then
				game.ReplicatedStorage.GameInProgress.Value = false
			end
			end
	end
end)


game.Workspace.WinBlock.Touched:connect(RestartTheGame)

game.Players.PlayerAdded:connect(function(NewPlayer)
	
	local PlayerCount = game.ReplicatedStorage.NumberOfPlayers.Value 
  
	PlayerCount = PlayerCount + 1
    
    if game.Players.NumPlayers > 1 and not game.ReplicatedStorage.GameInProgress.Value then
		game.ReplicatedStorage.GameInProgress.Value = true
    
		CountDown()
		PlayerToNumber()
		RandomSniper()
		SniperToPosition()
		PlayersToPosition()
	end
	
	NewPlayer.CharacterAdded:connect(function(Character)
		Character:WaitForChild("Humanoid").Died:connect(function()
			if game.ReplicatedStorage.GameInProgress.Value == true then
				if #Players1 > 0 then
				for i,v in pairs(Players1) do
					if v == NewPlayer.Name then
						table.remove(Players1,i)
						if #Players1 < 0 then
							game.ReplicatedStorage.GameInProgress.Value = false
							RestartTheGame()
							end
						end
					end
					end
				else
					game.ReplicatedStorage.GameInProgress.Value = false
					RestartTheGame()
				end
				end)
		end)
	end)

5 comments

1

Many more people would help if you gave us the line of the error.

0

Output only gave that error and a few print functions.

1

What line is the error on, we can't help without knowing where the error is

0

Why do i keep remembering this code.......

1

Looks like a bomb went off in the middle of your code. Please tab properly. Also, I have a hard time believing you wrote this if you don't know how to read an error correctly in the output.