Give point if two players are on the same team?

Hi.

So, I am trying to give a player one pass if they are on the same team as another player. I have two object values (both stored inside a part, soccer/football ball that you can kick).

One is the previous network owner of the ball, and one is the current network owner of the ball. Is there any way I could check if they are on the same team?

Current script I have:

if ball.Owner.Value ~= player then
		ball.OldOwner.Value = ball.Owner.Value
		ball:SetNetworkOwner(player)
		ball.Owner.Value = player
		
	local old = ball.OldOwner.Value -- this stores a players name
	local new = ball.Owner.Value -- this also stores a players name
	
	if old.TeamColor ~= new.TeamColor then
		old:FindFirstChild("Leaderstats").Passes.Value +=1
	end

Any help would be appreciated, thanks! :slightly_smiling_face:

your problem is your doing

if old.TeamColor ~= new.TeamColor then

instead of

if old.TeamColor == new.TeamColor then

you can also use Player.Team

if new.Team == old.Team then
    print("there in the same team")
    old.Leaderstats.Passes.Value += 1
else
    print("there NOT in the same team")
end
if new.Team ~= old.Team then
    print("there NOT in the same team")
else
    print("there in the same team")
    old.Leaderstats.Passes.Value += 1
end

see how == is different then ~=