Checking if a player is already in a team not working

I have a script that changes a player to a team using a gui, it checks if the player is already in that team and if the teams capacity is full. It all works except for the part that checks if they are already in the team, It completely ignores the line of code that does this, no error outputs and puts them in the team again and adds to the teams capacity. I know it is somewhat working because if I change it to if the player is in the team then do the follow it won’t execute the rest like it’s supposed to, not sure what I’m doing wrong.

local player = game.Players.LocalPlayer
local rm = game.ReplicatedStorage:WaitForChild("ChangeTeam")
local bot = script.Parent
local Count = bot:WaitForChild("Value")
local Menu = script.parent.parent
local TeamFull = Menu:WaitForChild("Team is full")
local Teams = game:GetService("Teams")

bot.MouseEnter:Connect(function()
	bot.ImageColor3 = Color3.new(255, 255, 255)

end)

bot.MouseLeave:Connect(function()
	bot.ImageColor3 = Color3.new(0.72549, 0.72549, 0.72549)

end)


bot.MouseButton1Click:Connect(function()
	
	if player.Team ~= bot.Name then -- bot.Name is the name of the team, works fine
		if Count.Value < 3 then
		Count.Value = Count.Value+1
			rm:FireServer(bot)
			print(Count.Value)
	else 
		TeamFull.Visible = true
		wait(3)
			TeamFull.Visible = false
		end
	end
end)

bot.Name is a string, player.Team is a Class. You should do

if player.Team.Name ~= bot.Name then
1 Like