First of all, instead of using all of those .Parent
's, you can use the shortcut game.Players.LocalPlayer
to get the player.
Second, to get the rank of someone, you can use player:GetRankInGroup( group ID )
:
http://wiki.roblox.com/index.php?title=API:Class/Player/GetRankInGroup
When implemented, your script would look like this:
01 | local requiredRankMinimum = 20 |
03 | local plr = game.Players.LocalPlayer |
06 | if plr:GetRankInGroup( 882106 ) > = requiredRankMinimum then |
07 | plr.TeamColor = BrickColor.new( "Industrial white" ) |
11 | script.Parent.MouseButton 1 Click:connect(Click) |
However, one thing I'd like to point out is that changing the team from a local script like that will not work if the game is Filtering Enabled. I recommend using a RemoteEvent to change the team.