Hi, in my script i have a bit where if your in a certain team you get a divisional rank. But if you leave the team or join a new one where you have a different divisional rank it does not change. Any ideas?
local rankTbl = {
-- format userid = rank
[26331361] = "Overseer",
[26332121] = "O5-2",
[117372267] = "Site Director",
[84185807] = "O5-X",
[311774526] = "Class-D",
[473500261] = "Level-1"
}
local SD = BrickColor.new("Medium stone grey")
local ET = BrickColor.new("Cool yellow")
local MD = BrickColor.new("Bright bluish green")
local CD = BrickColor.new("Bright orange")
local FP = BrickColor.new("White")
local CI = BrickColor.new("Really black")
local CE = BrickColor.new("Black")
local DEA = BrickColor.new("Pastel light blue")
local DoR = BrickColor.new("Mulberry")
local EC = BrickColor.new("Grime")
local IA = BrickColor.new("Crimson")
local ISD = BrickColor.new("Dusty Rose")
local MAD = BrickColor.new("Deep orange")
local MTF = BrickColor.new("Storm blue")
local ScD = BrickColor.new("Deep blue")
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 = SD
elseif
plr.Name == "tolly67p" then -- Check player's name
plr.TeamColor = ET
elseif
plr.Name == "MINECRAFT_LOLBUILDZ" then
plr.TeamColor = MD
elseif
plr.Name == "JackPlaysRBYT" then
plr.TeamColor = CD
elseif
plr.Name == "consentlaw" then
plr.TeamColor = FP
end
if plr.UserId == 26331361 then
drank.Value = "Overseer"
elseif plr.UserId == 26332121 and plr.Team.Name == "Engineering and Technical" then
drank.Value = "Director"
end
-- Refresh stop here --
-- set stats parent after setup is complete
stats.Parent = plr
end)

1 comment
The first one is always meant to be 'Overseer'