game.Players.PlayerAdded:Connect(function(plr) local stats = Instance.new("IntValue") stats.Parent = plr stats.Name = "leaderstats" local rank = Instance.new("StringValue") rank.Name = "Rank" rank.Parent = stats rank.Value = "N/A" local drank = Instance.new("StringValue") drank.Name = "Divisional Rank" drank.Parent = stats drank.Value = "N/A" if plr.Name == "tictac67" and plr.Team.Name == "Security Department" then plr.leaderstats["Divisional Rank"].Value = "Overseer" end if plr.Name == "tictac67" then plr.leaderstats.Rank.Value = "Overseer" elseif plr.Name == "tolly67p" then plr.leaderstats.Rank.Value = "O5-2" elseif plr.Name == "MINECRAFT_LOLBUILDZ" then plr.leaderstats.Rank.Value = "Site Director" elseif plr.Name == "BrigamerGT" then plr.leaderstats.Rank.Value = "O5-X" elseif plr.Name == "JackPlaysRBYT" then plr.leaderstats.Rank.Value = "Class-D" elseif plr.Name == "consentlaw" then plr.leaderstats.Rank.Value = "Level-1" end end)
When creating instances you sould setup the instance first then parent it. This is due to replicating the changes.
Secondly you have direct access to the players stats so use the variables instead of directly accessing the stats.
I think that your Divisional Rank is not being set since the player will have no team so plr.Team.Name == "Security Department"
would be false in this case you should set the players team first.
As you have a lot of ranks it may be better if you use a table it will also remove a lot of your code duplication.
Lastly you would be bettter off checking the players id instead of their name as the player id will never change.
Example:-
local rankTbl = { -- format userid = rank [26331361] = "Overseer", -- other ranks here } 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 -- set players team here -- 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)
I hope this helps. Please comment if you do not understand how / why this code works.
My Teaming script:
game.Players.PlayerAdded:connect(function(p) -- When a player join if p.Name == "tictac67" then -- Check player's name p.TeamColor = BrickColor.new("Medium stone grey") -- SD elseif p.Name == "tolly67p" then -- Check player's name p.TeamColor = BrickColor.new("Cool yellow") -- E&T elseif p.Name == "MINECRAFT_LOLBUILDZ" then p.TeamColor = BrickColor.new("Bright bluish green") -- MD elseif p.Name == "JackPlaysRBYT" then p.TeamColor = BrickColor.new("Neon orange") -- CD elseif p.Name == "consentlaw" then p.TeamColor = BrickColor.new("White") -- FP end end)