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

Any help with making this script change Divisional Rank when someone changes team?

Asked by 6 years ago
Edited 6 years ago
local rankTbl = {
    -- format userid  = rank 
    [26331361] = "Overseer",
    [26332121] = "O5-2",
    [117372267] = "Site Director",
    [84185807] = "O5-X",
    [311774526] = "Class-D",
    [473500261] = "Level-1"
}

game.Players.PlayerAdded:Connect(function(plr)
    local stats = Instance.new("IntValue")
    stats.Name = "leaderstats"

    local rank = Instance.new("StringValue")
    rank.Name = "Rank"
    rank.Value = rankTbl[plr.UserId]  or "N/A" -- if rankTbl[plr.UserId] is nil pass 'N/A'
    rank.Parent = stats -- safe to do since stats has a nil parent ie not ingame

    local drank = Instance.new("StringValue")
    drank.Name = "Divisional Rank"
    drank.Value = "N/A"
    drank.Parent = stats

    -- When a player join
    if plr.Name == "tictac67" then -- Check player's name
    plr.TeamColor = BrickColor.new("Medium stone grey") -- SD
    elseif
        plr.Name == "tolly67p" then -- Check player's name
    plr.TeamColor = BrickColor.new("Cool yellow") -- E&T
    elseif
        plr.Name == "MINECRAFT_LOLBUILDZ" then
    plr.TeamColor = BrickColor.new("Bright bluish green") -- MD
    elseif
        plr.Name == "JackPlaysRBYT" then
    plr.TeamColor = BrickColor.new("Neon orange") -- CD
    elseif
        plr.Name == "consentlaw" then
    plr.TeamColor = BrickColor.new("White") -- FP


end

    -- set stats
    if plr.UserId == 26331361 then -- check you team after it is set
        drank.Value = "Overseer"
    end

    -- set stats parent after setup is complete
    stats.Parent = plr
end)

Answer this question