So, I have a team change GUI that allows you to change team in that certain group, But how will you make it so it only changes the team if your rank is above 12?
Here's it so far-
function Click(mouse) if script.Parent.Parent.Parent.Parent.Parent:IsInGroup(882106) then script.Parent.Parent.Parent.Parent.Parent.TeamColor = BrickColor.new("Industrial white") end end script.Parent.MouseButton1Click:connect(Click)
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:
local requiredRankMinimum = 20 --To get rank IDs, look in your group admin page. local plr = game.Players.LocalPlayer function Click(mouse) if plr:GetRankInGroup(882106) >= requiredRankMinimum then plr.TeamColor = BrickColor.new("Industrial white") end end script.Parent.MouseButton1Click: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.