I've tried doing this:
player = game.Players.LocalPlayer
if player.Team == "RedTeam" then
print("worked")
end
It did not print what I asked it to, and showed no errors. And yes RedTeam is in game.Teams. Any help?
I've tried doing this:
player = game.Players.LocalPlayer
if player.Team == "RedTeam" then
print("worked")
end
It did not print what I asked it to, and showed no errors. And yes RedTeam is in game.Teams. Any help?
player = game.Players.LocalPlayer
if player.TeamColor == BrickColor.new("Bright red") then
print("worked")
end
There is no Team property of player. However, there is aTeamColorproperty. So, if we replace player.Team with player.TeamColor, and check for BrickColor.new("Bright red") (Or whichever teamcolor you're using) we can check the player's team.
Players don't contain a property which tells you their team directly, but they do have the TeamColor property. If you want to get the name of the team from that property, then you need to iterate through Teams until the colors match.
function GetTeamName(player)
if player.Neutral then return'Neutral'end
for _,v in pairs(game:GetService("Teams"):GetChildren())do
if v.TeamColor==player.TeamColor then
return v.Name
end
end
return'Neutral'
end
If multiple teams have the same color then this would return the first found.
If multiple teams had the same color then you would only be able to be on the first team.
This discussion is preserved as it was. New answers, comments, and votes are closed.
1 comment
Thanks!