(HELP!) Trouble w/ assigning teams on game

Hello! I have recently started working on a game that is going to be more of a death match type game mode thing. Everything was working fine and dandy but recently I started to encounter a problem with the team assignment. For some odd reason it is only teaming people to the “Drivers” team and not only this but putting them on the wrong spawn in the map where the “Runners” would spawn. I am re-using a system my friend made for a game we worked on a long time ago for another game. For this new game nothing is currently showing up in the output that is showing any errors but I believe the following script has something to do with it since it deals with much of the team assignment:

	local z = game.Workspace.GunSpawns:GetChildren()
	for i = 1,#z do
	local random1=math.random(1,9)
	if random1~=1 then
		local a=game.ReplicatedStorage.DropModels:GetChildren()
		local zz= a[ math.random( #a ) ]:Clone()
		zz.Parent=game.Workspace.DropModels
		zz:MoveTo(z[i].Position)
		zz.PrimaryPart.CFrame=zz.PrimaryPart.CFrame*CFrame.Angles(math.rad(math.random(1, 360)),0,0)
		game.Debris:AddItem(zz,100)
	end
end
end

function ScrambleTeams()
        local plrs = game.Players:GetPlayers()
        local x = 0

 local a,d = game.Teams.Drivers.TeamColor,game.Teams.Drivers.TeamColor
        while (#plrs > 0) do
                x = (x == 0 and 1 or 0)
                local ind = math.random(#plrs)
                local plr = plrs[ind]
		if plrs[ind]~=nil then
                plr.TeamColor = (x == 0 and a or d)
			                table.remove(plrs,ind)
                if (x == 1) then wait() end
			if plr~=nil then
			if plr.Character then
				plr:LoadCharacter()
				wait(.2)
		onSpawn(plr.Character)
				end
				end
				
			end
        end
end

function removeaccessories(avatar)
	local d = avatar:GetChildren() 
	for i=1, #d do 
		if (d[i].className == "Accessory") or (d[i].className == "Shirt") or (d[i].className == "Pants") then 
			d[i]:remove() 
			end
		end
end

function onSpawn(Char)
	if Char:FindFirstChild("Humanoid") then
		if game.Players:GetPlayerFromCharacter(Char) then
			local playerval=game.Players:GetPlayerFromCharacter(Char)
			if playerval~=nil and Char~=nil then
				Char.Humanoid.WalkSpeed=0
				wait(1)
				if playerval.TeamColor==BrickColor.new("Bright blue") then
					removeaccessories(Char)
					local a=game.ServerStorage.Uniformths.Drivers:GetChildren()
					for i=1, #a do 
						local v=a[i]:Clone()
						v.Parent=Char
					end
				elseif playerval.TeamColor==BrickColor.new("Bright red") then
										removeaccessories(Char)
					local a=game.ServerStorage.Uniforms.Runners:GetChildren()
					for i=1, #a do 
						local v=a[i]:Clone()
						v.Parent=Char
					end
					end
			end
		end
	end
end
		
while true do
	wait(2)
	if script.GameOver.Value==true then
	script.GameOver.Value=false
		script.GameStarted.Value=false
		script.GameInProgress.Value=false
		script.SecondsLeft.Value=0
	script.Status.Value="intermission"
		wait(5)
	script.Status.Value="starting new round"
	wait(4)
	local z = game.Workspace.DropModels:GetChildren()
	for i = 1,#z do
		z[i]:Remove()
	end
	local c = game.Workspace.Bodies:GetChildren()
	for b = 1,#c do
		c[b]:Remove()
	end
	ScrambleTeams()
	spawnguns()
	spawnguns()
	script.Status.Value="begin countdown"
	script.countdown2.Value=3
		wait(1)
		script.countdown2.Value=script.countdown2.Value-1
		wait(1)
		script.countdown2.Value=script.countdown2.Value-1
		wait(1)
		script.countdown2.Value=script.countdown2.Value-1
		script.GameStarted.Value=true
		script.countdown2.Value=script.countdown2.Value-1
			local players = game.Players:GetPlayers()
	for i = 1, #players do 
	    local player = players[i]
			if player.Character~=nil then
			player.Character.Humanoid.WalkSpeed=16
		end
	end
		script.Status.Value="round has began"
		script.GameInProgress.Value=true 
	
		script.SecondsLeft.Value=script.GameLength.Value
		wait(4)
		script.GameStarted.Value=false
		script.Status.Value="game in-progress"
		end
end

local function onPlayerAdded(player)
	player.CharacterAdded:Connect(onSpawn)
end

game.Players.PlayerAdded:Connect(onPlayerAdded)

I am new to scripting and trying to learn so please try to dumb down your responses if you can lol.