0
votes

So basically I was scripting a military game in Roblox and there I want to add an overhead gui showing people's rank in group. If only one player is there in the game it works fine, but if another player joins it goes off the first player head and displays on the second player head with first person's name and second person's rank! I have tried different codes but it didnt solve.

Here is the main code:

local conf = require(script.config)
local bb = game.ServerStorage.Tag
game.Players.PlayerAdded:Connect(function(plr)
    plr.CharacterAdded:Connect(function(character)
        wait(3)
        local color
        
        for k, v in pairs(conf.config) do
            if plr:GetRankInGroup(14759188) == v.Min and plr:GetRankInGroup(14759188) <= v.Max then
                color = v.rankcolor
            end     
        end
        
        local cloned = bb:Clone()
        cloned.Parent = character:WaitForChild("Head")
        cloned.Adornee =character:WaitForChild("Head")
        local ranking = plr:GetRoleInGroup(14759188)
        cloned.RankTag.TextColor3 = color
        cloned.RankTag.Text = ""..ranking
        cloned.User.Text = plr.Name
    end)
end)

And here is the config file:

local conf = {}
conf.config = {
{
    Name = "CDS",
    Min = 255,
    Max = 255,
    rankcolor = Color3.new(0.988235, 1, 0.137255)
},
{
    Name = "CGS",
    Min = 26,
    Max = 255,
    rankcolor = Color3.new(0.988235, 1, 0.137255)   
},
{
    Name = "CDEV",
    Min = 25,
    Max = 255,
    rankcolor = Color3.new(0.454902, 1, 0.0392157)  
},
{
    Name = "DEV",
    Min = 24,
    Max = 255,
    rankcolor = Color3.new(0.262745, 1, 0.0588235)
},
{
    Name = "DCGS",
    Min = 23,
    Max = 255,
    rankcolor = Color3.new(0.941176, 1, 0.254902)
},
{
    Name = "ACGS",
    Min = 22,
    Max = 255,
    rankcolor = Color3.new(0.988235, 1, 0.235294)   
},
{
    Name = "ASM",
    Min = 21,
    Max = 255,
    rankcolor = Color3.new(1, 0.721569, 0.0627451)
},
{
    Name = "OF-9",
    Min = 20,
    Max = 255,
    rankcolor = Color3.new(1, 0.639216, 0.137255)
},
{
    Name = "OF-8",
    Min = 19,
    Max = 255,
    rankcolor = Color3.new(1, 0.568627, 0.215686)
},
{
    Name = "OF-7",
    Min = 18,
    Max = 255,
    rankcolor = Color3.new(1, 0.431373, 0.101961)
},
{
    Name = "OF-6",
    Min = 17,
    Max = 255,
    rankcolor = Color3.new(1, 0.380392, 0.258824)
},
{
    Name = "OF-5",
    Min = 16,
    Max = 255,
    rankcolor = Color3.new(1, 0.458824, 0.321569)
},
{
    Name = "OF-4",
    Min = 15,
    Max = 255,
    rankcolor = Color3.new(1, 0.2, 0.129412)
},
{
    Name = "OF-3",
    Min = 14,
    Max = 255,
    rankcolor = Color3.new(0.905882, 0.270588, 0.0588235)
},
{
    Name = "OF-2",
    Min = 13,
    Max = 255,
    rankcolor = Color3.new(0.258824, 0.396078, 1)
},
{
    Name = "OF-1",
    Min = 12,
    Max = 255,
    rankcolor = Color3.new(0.207843, 0.352941, 1)
},
{
    Name = "OR-9B",
    Min = 11,
    Max = 255,
    rankcolor = Color3.new(0.305882, 0.454902, 1)
},
{
    Name = "OR-9",
    Min = 10,
    Max = 255,
    rankcolor = Color3.new(0.0784314, 0.52549, 1)
},
{
    Name = "OR-8B",
    Min = 9,
    Max = 255,
    rankcolor = Color3.new(0, 0.768627, 1)  
},
{
    Name = "OR-8",
    Min = 8,
    Max = 255,
    rankcolor = Color3.new(0.333333, 0.666667, 0.498039)
},
{
    Name = "OR-7",
    Min = 7,
    Max = 255,
    rankcolor = Color3.new(0.0627451, 0.345098, 0.498039)   
},
{
    Name = "OR-6",
    Min = 6,
    Max = 255,
    rankcolor = Color3.new(0.556863, 1, 0.682353)
},
{
    Name = "OR-5",
    Min = 5,
    Max = 255,
    rankcolor = Color3.new(1, 0.784314, 0.482353)
},
{
    Name = "OR-4",
    Min = 4,
    Max = 255,
    rankcolor = Color3.new(0.541176, 1, 0.411765)
},
{
    Name = "OR-3",
    Min = 3,
    Max = 255,
    rankcolor = Color3.new(0.564706, 1, 0.27451)
},
{
    Name = "OR-2",
    Min = 2,
    Max = 255,
    rankcolor = Color3.new(0.666667, 0, 1)  
},
{
    Name = "OR-1",
    Min = 1,
    Max = 255,
    rankcolor = Color3.new(0.423529, 0.282353, 0.121569)    
},
{
    Name = "CIV",
    Min = 0,
    Max = 255,
    rankcolor = Color3.new(0.419608, 0.419608, 0.419608)
},
}
return conf

Please see if you can help me :)