Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How could I fix this rank script?

I made a simple rank script and it works fine and all, but when I use the debug command using lmm admin or die/respawn, it makes the rank disappear. How could I stop the rank from disappearing?

--Place the script named Rank Script in Workplace
--Place the BillboardGui named Rank in ServerStorage
--Created by centerspell
ranks = {
    [0] = Color3.new(255/255, 255/255, 255/255),
    [1] = Color3.new(255/255, 255/255, 255/255),
    [70] = Color3.new(255/255,0/255,0/255),
    [90] = Color3.new(182/255, 54/255, 54/255),
    [130] = Color3.new(255/255, 255/255, 0/255),
    [140] = Color3.new(255/255, 255/255, 0/255),
    [150] = Color3.new(0/255, 255/255, 0/255),
    [175] = Color3.new(40/255, 172/255, 40/255),
    [210] = Color3.new(0/255, 94/255, 255/255),
    [230] = Color3.new(0/255, 230/255, 255/255),
    [254] = Color3.new(255/255, 145/255, 0/255),
    [255] = Color3.new(222/255, 0/255, 255/255)
}

game.Players.PlayerAdded:connect(function(plr)
    local rank = plr:GetRankInGroup(1130688)
    local role = plr:GetRoleInGroup(1130688)
    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)

1 answer

You're missing the CharacterAdded event, this event will execute every time your player respawns.

Just put it in the PlayerAdded function.

--Place the script named Rank Script in Workplace
--Place the BillboardGui named Rank in ServerStorage
--Created by centerspell
ranks = {
    [0] = Color3.new(255/255, 255/255, 255/255),
    [1] = Color3.new(255/255, 255/255, 255/255),
    [70] = Color3.new(255/255,0/255,0/255),
    [90] = Color3.new(182/255, 54/255, 54/255),
    [130] = Color3.new(255/255, 255/255, 0/255),
    [140] = Color3.new(255/255, 255/255, 0/255),
    [150] = Color3.new(0/255, 255/255, 0/255),
    [175] = Color3.new(40/255, 172/255, 40/255),
    [210] = Color3.new(0/255, 94/255, 255/255),
    [230] = Color3.new(0/255, 230/255, 255/255),
    [254] = Color3.new(255/255, 145/255, 0/255),
    [255] = Color3.new(222/255, 0/255, 255/255)
}

game.Players.PlayerAdded:connect(function(plr)
plr.CharacterAdded:connect(function() --So a new character is in use.
    local rank = plr:GetRankInGroup(1130688)
    local role = plr:GetRoleInGroup(1130688)
    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)
end)

This discussion is preserved as it was. New answers, comments, and votes are closed.