Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How would you make this team GUI script only change team for a certain rank?

Asked by
s_21 74
6 years ago

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) 

1 answer

Log in to vote
1
Answered by 6 years ago

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.

Ad

Answer this question