Ok so..It seems to be happening before Line 66. It sets everyones team... but then it sets them back to spectating. Idk y. ive spent like an 2 hours trying to figure out why. its probably something stupid too.

local InProgress = false
local TeamService = game:GetService("Teams")

game:GetService('Players').PlayerAdded:Connect(function(player)
	print("Player Joined")
	game.Teams.IntermissionP.Value = game.Teams.IntermissionP.Value + 1
	player.CharacterAdded:Connect(function(character)
		character:WaitForChild("Humanoid").Died:Connect(function()
			if player.TeamColor == BrickColor.new("Really red") and InProgress == true then
				TeamService.RedP.Value = TeamService.RedP.Value - 1
				player.TeamColor = BrickColor.new("Medium stone grey")
				print("Red player died.")
			end
			if player.TeamColor == BrickColor.new("Really blue") and InProgress == true then
				TeamService.BlueP.Value = TeamService.BlueP.Value - 1
				player.TeamColor = BrickColor.new("Medium stone grey")
				print("Blue player died.")
			end
			if player.TeamColor == BrickColor.new("Medium stone grey") then
				print("Spectating dude died.")
			end
		end)
	end)
end)



function Start()
	TeamService.Spectating.AutoAssignable = false
	wait(1)
	TeamService.BlueP.Value = 0
	TeamService.RedP.Value = 0
	local Players = game:GetService("Players"):GetChildren()
	local teams = {"Really blue","Really red"}
	local number = 1
    for _, player in pairs(game.Teams.Spectating:GetPlayers()) do
		player.TeamColor = BrickColor.new(teams[number])
		print(player.TeamColor)
		number = number + 1
		if number > #teams then
			number = 1
		end
    end
	wait(1)
	game:GetService("Lighting").ClockTime = math.random(1, 23)
	print(game:GetService("Lighting").ClockTime .. " Time of Day.")
	for i = 1, #Players do
		if Players[i].TeamColor == BrickColor.new("Really red") then
			TeamService.RedP.Value = TeamService.RedP.Value + 1
			print(TeamService.RedP.Value .. "Red team players.")
		end
		if Players[i].TeamColor == BrickColor.new("Really blue") then
			TeamService.BlueP.Value = TeamService.BlueP.Value + 1
			print(TeamService.BlueP.Value .. "Blue team players.")
		end
		Players[i]:LoadCharacter()
		wait(0.5)
		Players[i].Character.Humanoid.WalkSpeed = 0
		game:GetService("ServerStorage").ValScript:Clone().Parent = Players[i].Backpack
		game:GetService("ServerStorage").NightVision:Clone().Parent = Players[i].Backpack
		print("Copied Gun and NV for" .. Players[i].Name)
	end
	InProgress = true
	TeamService.IntermissionP.Value = 0
	print("No intermission players.")
	x = Instance.new("Message")
	x.Parent = workspace
	x.Text = "Eliminate the other team."
	wait(3)
	x.Text = "5"
	wait(1)
	x.Text = "4"
	wait(1)
	x.Text = "3"
	wait(1)
	x.Text = "2"
	wait(1)
	x.Text = "1"
	wait(1)
	x.Text = "GO!"
	wait(1)
	x:Destroy()
	for i = 1, #Players do
		Players[i].Character.Humanoid.WalkSpeed = 16
	end
	print("Game Officialy Started.")
end



game.Players.PlayerRemoved:Connect(function(playerok)
	local Players = game:GetService("Players"):GetChildren()
	if InProgress == false then
		game.Teams.IntermissionP.Value = game.Teams.IntermissionP.Value - 1
	end
	if InProgress == true then
		if playerok.TeamColor == BrickColor.new("Really red") then
			TeamService.RedP.Value = TeamService.RedP.Value - 1
		end
		if playerok.TeamColor == BrickColor.new("Really blue") then
			TeamService.BlueP.Value = TeamService.BlueP.Value - 1
		end
	end
end)



function End()
	TeamService.Spectating.AutoAssignable = true
	local Players = game:GetService("Players"):GetChildren()
	if TeamService.RedP.Value == 0 and InProgress == true then
		x = Instance.new("Message")
		x.Parent = workspace
		x.Text = "Swat wins!"
		wait(3)
		x:Destroy()
	elseif TeamService.BlueP.Value == 0 and InProgress == true then
		x = Instance.new("Message")
		x.Parent = workspace
		x.Text = "Terrorists wins!"
		wait(3)
		x:Destroy()
	end
	InProgress = false
	for i = 1, #Players do
		Players[i].TeamColor = BrickColor.new("Medium stone grey")
		Players[i]:LoadCharacter()
		Players[i].Character.Humanoid.WalkSpeed = 0
	end
	TeamService.RedP.Value = 0
	TeamService.BlueP.Value = 0
	TeamService.IntermissionP.Value = #Players
end
TeamService.RedP.Changed:Connect(End)
TeamService.BlueP.Changed:Connect(End)

while InProgress == false do
	wait(10)
	if TeamService.IntermissionP.Value >= 2 then
		Start()
	end
end

6 comments

0

the values RedP and BlueP seem to not change even though it should. Stated in lines 50 and 54. Also the game doesnt seem to restart if i end it by changing the values...

0

connect is deprecated use Connect. Messages are also deprecated, use GUIs instead.You also shouldn't be using ChildAdded/ChildRemoved, as this applies to any object in general, not Player objects exclusively. Use PlayerAdded/PlayerRemoving.

1

Can you localize the Varibles that are used more than once to the top of the script please cause it would make the script a lot cleaner. for example you have game:GetService("Teams"), on so many lines when you could of done local Teams = game:GetService("Teams") on top then put Teams where game:GetService("Teams") used to be

0

^

0

Ok, i updated it. but can you find any problems with it? those were my main questions.

0

Ok.....It was lines 47-55