Hello there!
Is there any way to team a certain player to a certain team every time they join the game? I would like to make it so that an HR in a group will join the game always on a certain team. How would I script this?
1 Like
Hello so I believe this should work for what you are asking for:
local HRColor = "Teal" -- This is were you put your MR team color.
game.Players.PlayerAdded:Connect(function(plr)
if plr:GetRankInGroup (6559630) == 255 then -- This is were you need to put your group ID + role you want to get the team. If you want to add extra just add a or between.
plr.TeamColor = BrickColor.new(MRColor)
print ("Player is MR")
end
end)
`
3 Likes
GetRankInGroup may error; I recommend you use an auto-retry pcall system.
Why would it error? It works fine for me.
1 Like
It’s a web call; like datastores, it can error.
However, if datastores fail, that’s a big deal, and pcall should be used. In this case, it’s not as big of a deal as players losing data. It’s unnecessary in this use case.
GetRankInGroup will not error… The documentation does not say this and I’ve used this for years and it doesn’t error. I recommend reading up on the documentation.
As for the OP, GetRankInGroup combined with game.Players.PlayerAdded will suffice.
1 Like