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

What is wrong with this rank script?[Not Answered]

Asked by 9 years ago

I made a rank script that is supposed to show your group rank over your head in a certain color. It shows your rank number instead of the name and it isn't colored. Please help me fix this script since i don't know what is wrong with it. I have tried multiple things like changing role to rank, keeping it just if role == "rank name" or just if rank == rank number. There are no errors in the console.

game.Players.PlayerAdded:connect(function(plr)
    plr.CharacterAdded:connect(function(char)
        local rank = plr:GetRankInGroup(1148703)
        local role = plr:GetRoleInGroup(1148703)
        local color = Color3.new(255/255, 255/255, 255/255)
        if rank == 0 and role == "Guest" then
            role = "Guest"
            color = color3.new(255/255, 255/255, 255/255)
        elseif rank == 10 and role == "Member" then
            role = "Member"
            color = Color3.new(255/255, 255/255, 255/255)
        elseif rank == 145 and rank == "Abuse Reporter" then
            role = "Abuse Reporter"
            color = Color3.new(117/255, 69/255, 71/255)
        elseif rank == 155 and role == "Trial-Moderator" then
            role = "Trial-Moderator"
            color = Color3.new(0/255, 0/255, 0/255)
        elseif rank == 165 and role == "Moderator" then
            role = "Moderator"
            color = Color3.new(52/255, 117/255, 0/255)
        elseif rank == 175 and role == "Head-Moderator" then
            role = "Head-Moderator"
            color = Color3.new(255/255, 149/255, 0/255)
        elseif rank == 185 and role == "Supervisor" then
            role = "Supervisor"
            color = Color3.new(17/255, 0/255, 255/255)
        elseif rank == 195 and role == "Manager" then
            role = "Manager"
            color = Color3.new(117/255, 107/255, 255/255)
        elseif rank == 205 and role == "Administrator" then
            role = "Administrator"
            color = Color3.new(54/255, 14/255, 255/255)
        elseif rank == 215 and role == "Head-Administrator" then
            role = "Head-Administrator"
            color = Color3.new(19/255, 255/255, 7/255)
        elseif rank == 216 and role == "Chief Staff Officer" then
            role = "Chief Staff Officer"
            color = Color3.new(139/255, 1/255, 132/255)
        elseif rank == 217 and role == "Chief Operational Officer" then
            role = "Chief Operational Officer"
            color = Color3.new(254/255, 255/255, 180/255)
        elseif rank == 218 and role == "Chief Executive Officer" then
            role = "Chief Executive Officer"
            color = Color3.new(1/255, 74/255, 74/255)
        elseif rank == 225 and role == "Developer" then
            role = "Developer"
            color = Color3.new(138/255, 138/255, 138/255)
        elseif rank == 235 and role == "Co-Owner" then
            role = "Co-Owner"
            color = Color3.new(8/255, 255/255, 239/255)
        elseif rank == 245 and role == "Group Owner" then
            role = "Group Owner"
            color = Color3.new(255/255, 8/255, 235/255)
        elseif rank == 255 and role == "Mod King -Owner-" then
            role = "Mod King -Owner-"
            color = Color3.new(255/255, 0/255, 0/255)
        end
        print(plr.Name.." just joined with rank '"..role.."'")
        if rank ~= "Guest" then
            local rankd = game.ServerStorage.Rank:Clone()
            rankd.Parent = char.Head
            rankd.TextLabel.Text = rank
            rankd.TextLabel.TextColor3 = color
        end
    end)
end)
0
Is this inside a LocalScript? gskw 1046 — 9y
0
This is a server side script that connects with a gui inside of Server Storage Alpha_Toon 57 — 9y

1 answer

Log in to vote
1
Answered by 9 years ago

Assuming that rankd is a BillboardGui, and this is a server sided (regular) script this should work:

ranks = {
    [0] = Color3.new(1,1,1),
    [10] = Color3.new(1,1,1),
    [145] = Color3.new(117/255,69/255,71/255),
    [155] = Color3.new(0,0,0),
    [165] = Color3.new(52/255,117/255,0/255),
    [175] = Color3.new(1,149/255,0),
    [185] = Color3.new(17/255,0,1),
    [195] = Color3.new(117/255,107/255,1),
    [205] = Color3.new(54/255,14/255,1),
    [215] = Color3.new(19/255,1,7/255),
    [216] = Color3.new(139/255,1/255,132/255),
    [217] = Color3.new(254/255,1,180/255),
    [218] = Color3.new(1/255,74/255,74/255),
    [225] = Color3.new(138/255,138/255,138/255),
    [235] = Color3.new(8/255,1,239/255),
    [245] = Color3.new(1,8/255,235/255),
    [255] = Color3.new(1,0,0)
}

game.Players.PlayerAdded:connect(function(plr)
    local rank = plr:GetRankInGroup(1148703)
    local role = plr:GetRoleInGroup(1148703)
    if rank ~= 0 then
        local rankd = game.ServerStorage.Rank:Clone()
        repeat wait() until plr.Character
        rankd.Parent = plr.Character.Head
        rankd.TextLabel.Text = role
        rankd.TextLabel.TextColor3 = ranks[rank]
    end
end)

Your mistake was most likely in line 59 where you were trying to compare rank to role. Rank is the number of the rank, and role is the name of the rank. Furthermore, I have taken the freedom to much simplify the code by using a table to store the different colours of the ranks, and to use the role that Roblox provides us rather than trying to manually set the role again.

0
I get an error saying } is supposed to close { at line one. Alpha_Toon 57 — 9y
0
Try copy pasting again. juzzbyXfalcon 155 — 9y
0
My bad, I have only now been able to test it in Roblox studio as I was at work earlier. My mistake was one comma to much and my keys were not in []'s. Edited the post. Please try again. juzzbyXfalcon 155 — 9y
0
I just had to change one thing which i think you did by accident which was change ranks[role] to ranks[rank] but it works. Alpha_Toon 57 — 9y
0
Whoops, you're absolutely right! I'll edit the post for people who come here in the future. juzzbyXfalcon 155 — 9y
Ad

Answer this question