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

Help with Team Change Rank GUI?

Asked by 9 years ago

Okay, I'm making a group. That is based off of the Secure Contain Protect foundation. Now, I need help making it so only a certain rank. Can switch to the Foundation Personnel team. I need the rank number as 1. The code below shows the basic team change, but I need help making it so only ranks can switch to this team through roblox groups. Please respond if you have the time, thank you.

function Click(mouse) if script.Parent.Parent.Parent.Parent.Parent:IsInGroup(703942) then script.Parent.Parent.Parent.Parent.Parent.TeamColor = BrickColor.new("Bright blue") end end

script.Parent.MouseButton1Click:connect(Click)

2 answers

Log in to vote
0
Answered by 9 years ago

Alright, try using a Lua Code block next time, so it can make your code clearer and easier to understand. From what you said on the description it seems as if you want a certain rank on your group to access a team. For that, we must use the 'GetRankInGroup() == 'Rank Number' method.

Your script would look like this: Note: I made your code a bit simpler, so that you wouldn't need to call every 'Parent' of the object to get the player.

Player = game.Players.LocalPlayer
function Click(mouse) 
    if Player:IsInGroup(--[[GroupID]]) and Player:GetRankInGroup(--[[GroupID]]) == 1 --[[Rank # Example:"1" or "255" etc]] then 
    Player.TeamColor = BrickColor.new("TeamColor") 
    end 
end 

script.Parent.MouseButton1Click:connect(Click) 

If you want to make it so that every person above rank '1', including rank '1' to be able to join the Team, you must use >= (greater than or equal to). Same with less than <= . If you just want it to be one rank, as above only use two '=' signs. Hope this helped.

0
Thanks for the fast reply! But it didn't work for me, This is how I pasted my code. Please tell me if I did something wrong. Electrolyke 0 — 9y
0
Player = game.Players.LocalPlayer function Click(mouse) if Player:IsInGroup(2641004) and Player:GetRankInGroup(2641004) >= 2 --[[Rank # Example:"1" or "255" etc]] then Player.TeamColor = BrickColor.new("White") end end script.Parent.MouseButton1Click:connect(Click) Electrolyke 0 — 9y
0
Did you insert the script into a 'Clickable' TextButton? PresidentAlvarez 5 — 9y
0
It's already inside one. Electrolyke 0 — 9y
Ad
Log in to vote
0
Answered by 9 years ago

This might work:

--In a localscript inside the button
local Player = game.Players.LocalPlayer

script.Parent.MouseButton1Down:connect(function()
    if Player:GetRankInGroup(--GroupId) > 1 then
        Player.TeamColor = BrickColor.new(--BrickColor)
    end
end)

Answer this question