.Changed not Firing

Hello, I am trying to fire a function when the player switches teams but it won’t fire,

Plr.Team.Changed:Connect(function()
	if Plr.Team.Name == "Civilian" then
		ShirtsButton.Text = "White Tee"
		SetShirt(WhiteTee)
	elseif Plr.Team.Name == "Military" then
		ShirtsButton.Text = "Army Combats"
		SetShirt(CombatsTop)
	end
end)

(It is in a local script)

Not 100% on this but pretty sure Player.Team does not have a Changed event - you need to use GetPropertyChangedSignal.

1 Like

Would you be able to use, “Team.Name.Changed” ?

You can’t do that with Changed. You can use this:

Team:GetPropertyChangedSignal("Name"):Connect(function()
    print("The team name has been changed")
end)
Plr.Team:GetPropertyChangedSignal("Name"):Connect(function()
	if Plr.Team.Name == "Civilian" then
		ShirtsButton.Text = "White Tee"
		SetShirt(WhiteTee)
	elseif Plr.Team.Name == "Military" then
		ShirtsButton.Text = "Army Combats"
		SetShirt(CombatsTop)
	end
end)

Tried this, it won’t fire.

It will fire. Its just you don’t really get the team like that. Sometimes the team does not load in time and the script can’t get it. Use WaitForChild(). It will wait until the team is loaded.

Team is a property, not a child.

Here you go.
Plr:GetPropertyChangedSignal("Team"):Connect(function()

Oh yea I completely forgot about that. Havent used teams in a while.