Why is my team-only vehicle script not working?

I made a vehicle with a proximity prompt and now I am trying to make it only drivable if the player is on a certain team and it isn’t working.

Regardless of which team I am on it prints the else.

local vehicle = script.Parent.Parent.Parent
local body = vehicle.Body
local seat = script.Parent.Parent
local colorPart = script.Parent.Red

local proximityPrompt = seat.ProximityPrompt

seat:GetPropertyChangedSignal("Occupant"):Connect(function() 

	if seat.Occupant then
		proximityPrompt.Enabled = false	
	else
		proximityPrompt.Enabled = true	
	end
end)

proximityPrompt.Triggered:Connect(function(player)

	if player.Team.Name == colorPart.Name then
		seat:Sit(player.Character.Humanoid)
	else
		
		print(player.Name .. " tried to enter the wrong team's vehicle.")
		
	end
end)

What is this? I think you forgot to add something here.

This is used to check if the vehicle has a driver (or if the seat is occupied), and hides the prompt that lets you into that seat. If I didn’t add this, you would still be able to enter a seat that another person is sitting in.

Your code seems to work for me, but maybe you could do

if player.Team == game.Teams.teamNameHere then
		seat:Sit(player.Character.Humanoid)
	else
		
		print(player.Name .. " tried to enter the wrong team's vehicle.")
		
	end