How can I fix my leaderboard/nametag script?

I’m trying to create a script that creates a leaderboard that lists everybody’s rank and gives them an above-head nametag, with the same rank. However, for some reason, the script doesn’t work. Upon testing in-studio, the output shows no errors. The script itself also shows no errors.

I also added some print functions at several points within the script, and only 3 of the 6 have worked. In-studio, there were zero changes or errors prior to adding the prints.


Code
local billboard = script.BillboardGui
print("Begin")
game.Players.PlayerAdded:Connect(function(Player)
	Player.CharacterAdded:Connect(function(char)
			print("Mid1")
			local RankAbrv = "Rank Loading"
       			local GR = Player:GetRankInGroup(5290077)
       				if GR == 15 then RankAbrv = "Pending"
      			    elseif GR == 45 then RankAbrv = "SUSPICOUS"
        			elseif GR == 75 then RankAbrv = "Polar"
        			elseif GR == 90 then RankAbrv = "Ardent"
        			elseif GR == 105 then RankAbrv = "Team"
        			elseif GR == 120 then RankAbrv = "Kinetic"
        			elseif GR == 135 then RankAbrv = "Advancement"
        			elseif GR == 150 then RankAbrv = "Order"
        			elseif GR == 165 then RankAbrv = "Developer"
        			elseif GR == 180 then RankAbrv = "Ally"
        			elseif GR == 195 then RankAbrv = "International"
        			elseif GR == 210 then RankAbrv = "Blaze"
        			elseif GR == 225 then RankAbrv = "Morning"
	        		elseif GR == 250 then RankAbrv = "Council"
       				elseif GR == 252 then RankAbrv = "Commander"
       				elseif GR == 255 then RankAbrv = "older"
        			elseif GR == 0 then RankAbrv = "Guest"
        			elseif Player.name == "AFuturisticFox" then RankAbrv = "Ally"
        			elseif Player.name == "MainDragon1971" then RankAbrv = "Ally"    

--------------------------------------------------------------------------------------------------------------------------------------
print("Mid2")
local Stats = Instance.new("IntValue")
	Stats.Name = "leaderstats"
    
local Rank = Instance.new("StringValue")
	Rank.Name = "Rank"
	Rank.Value = RankAbrv

    Rank.Parent = Stats

--------------------------------------------------------------------------------------------------------------------------------------
print("Mid3")
local CloneGUI = billboard:Clone()
local Usrnm = Player.name 
    
	CloneGUI.Parent = char.Head
	
    	CloneGUI.Rank.TextTransparency = 0
   		CloneGUI.Rank.Text = "["..RankAbrv.."]"
            
   		CloneGUI.Username.TextTransparency = 0
   		CloneGUI.Username.Text = Usrnm 
           
    print("Mid4")
end
end)
end)
print("End")

Prints

Of the six, only “Begin”, “End”, and “Mid1” printed.


Images

Explorer Tree:
image

In-studio testing (Nothing appears):


Small Fixes

@Minstrix mentioned adding an end to my elseifs. While this did allow all of my print functions to work, and assign an above-head nametag, it still hasn’t set the leaderboard, oddly enough.

I’ve been struggling to solve this for a while, thanks!

1 Like

Just from quickly glancing over it, I believe that you’re missing an end after the big if elseif chain.

1 Like

That slightly solved the problem, thanks!

Now, all prints printed, and it gave me an above-head nametag. However, the leaderboard didn’t load…

1 Like

it might be me but your leaderstats are an intvalue instead of a folder?

local Stats = Instance.new("IntValue")
	Stats.Name = "leaderstats"
2 Likes

I changed it to an IntValue while trying to ix it, however, changing it back to a leaderstats folder didn’t change anything. But good catch! Thanks!

local function onPlayerJoin(player)
	local leaderstats = Instance.new("Folder")
	leaderstats.Name = "leaderstats"
	leaderstats.Parent = player
end

Aditionally you should make your elseifs into ranges If it’s greater than or equal to 45 and less than or equal to 49. If they are GR 47, they still have a rank in their leaderstats.

1 Like

Ah, after looking at @Steve_Speedy’s post, just remembered you have to parent it to the player for it to appear as well.

And yes, I think it has to be a folder

2 Likes

Thanks! I forgot to use onPlayerJoin.

1 Like