Allein277
(Allein)
December 13, 2020, 10:54pm
#1
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)
Matthais5
(Matthais5)
December 13, 2020, 10:55pm
#2
Not 100% on this but pretty sure Player.Team
does not have a Changed
event - you need to use GetPropertyChangedSignal
.
1 Like
Allein277
(Allein)
December 13, 2020, 11:06pm
#3
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)
Allein277
(Allein)
December 13, 2020, 11:20pm
#5
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.