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

How do I make it so if the person is in another group it will show that rank instead of this one?

Asked by 6 years ago
local User = script:WaitForChild("Username")
local Rank = script:WaitForChild("Rank")
local Regiment = script:WaitForChild("Regiment")

game.Players.PlayerAdded:connect(function(Player)
    Player.CharacterAdded:connect(function(Character)
        spawn(function()
            wait(.8)
            local c = User:clone()
            local a = Rank:clone()
            local b = Regiment:clone()
            a.Adornee = Character:WaitForChild("Head")
            a.TextLabel.Text = Player:GetRoleInGroup(4186798)
            a.Enabled = true
            a.Parent = Character 
            b.Adornee = Character:WaitForChild("Head")
            b.TextLabel.Text = Player:GetRoleInGroup(4186863)
            b.TextLabel.TextColor3 = (Player.TeamColor.Color)
            b.Enabled = true
            b.Parent = Character
            c.Adornee = Character:WaitForChild("Head")
            c.TextLabel.TextColor3 = (Player.TeamColor.Color)
            c.TextLabel.Text = Player.Name
            c.Enabled = true
            c.Parent = Character
            Character:WaitForChild('Humanoid').NameOcclusion = Enum.NameOcclusion.OccludeAll
            local h = Character.Head:Clone()
            local m = Instance.new('Model',Character)
            m.Name = 'NameTag'
            h.Parent = m
            Character.Head:WaitForChild('face'):Destroy()
            Character.Head.Transparency = 1
            local w = Instance.new('Weld',Character.Head)
            w.Part0, w.Part1 = Character.Head, h
        end)
    end)
end)

1 answer

Log in to vote
0
Answered by 6 years ago

Well I'm not completely sure of what you're trying to do, but from the question it seems like a really simple problem.

The thing you can do to check if the person is in another group just use if, elseif statements:

if plr:GetRankInGroup(id1) > 0 then --id1 is the group id of the 1st group by priority
    --add a label showing the role in group1
elseif plr:GetRankInGroup(id2) > 0 then --id2 is the group id of the 2nd group by priority
    --add a label showing the role in group1
end

Basically all you have to do is get the correct ids of the groups you wanna check and make sure they are in the order from the highest to the lowest priority. Of course you have to adjust the script a bit to work as you want and you have to change the labels with role by yourself but that shouldn't be a problem since you already did that in your script.

Ad

Answer this question