Leaderboard Character Overhead GUI not showing up

I have a donation board and next to it is a statue on which the first player on the leaderboard is dancing, an overhead gui should appear saying that they are #1, their username and how many they have donated, but the gui is not appearing here is the whole script:

local Players = game:GetService("Players")
local DataStoreService = game:GetService("DataStoreService")
local MarketplaceService = game:GetService("MarketplaceService")

local DonationsDS = DataStoreService:GetOrderedDataStore("DonationsLeaderboard")
_G.DonationsDS = DonationsDS -- make global

local DonationLB = workspace:WaitForChild("DonationLB")
local LeaderboardPart = DonationLB:WaitForChild("LeaderboardPart")
local LeaderboardGui = LeaderboardPart:WaitForChild("LeaderboardGui")
local PlayerHolder = LeaderboardGui:WaitForChild("FrameHolder"):WaitForChild("PlayerHolder")
local Statue = DonationLB:WaitForChild("GreenStatue")
local StatueCharacter = Statue:WaitForChild("Character")
local Sample = script:WaitForChild("Sample")

local RefreshTime = 60

-- Hide the sample frame
local PlayerHolderSample = PlayerHolder:FindFirstChild("Sample")
if PlayerHolderSample then
	PlayerHolderSample.Visible = false
end

-- Helper: Add commas to numbers
local function commaValue(n)
	local left, num, right = tostring(n):match('^([^%d]*%d)(%d*)(.-)$')
	return left .. (num:reverse():gsub("(%d%d%d)", "%1,"):reverse()) .. right
end

-- Apply player appearance to a model
local function setRigAppearance(characterModel, userId)
	task.spawn(function()
		local success, description = pcall(function()
			return Players:GetHumanoidDescriptionFromUserId(userId)
		end)
		if success and description and characterModel then
			local humanoid = characterModel:FindFirstChildOfClass("Humanoid")
			if humanoid then
				humanoid:ApplyDescription(description)
			end
		else
			warn("Failed to apply description for userId " .. tostring(userId))
		end
	end)
end

-- Update statue overhead display
local function updateStatueOverhead(userId, donated)
	local head = StatueCharacter:FindFirstChild("Head")
	if not head then return end

	local overheadGui = head:FindFirstChild("OverheadGui")
	if not overheadGui then return end

	local frame = overheadGui:FindFirstChild("Frame")
	if not frame then return end

	local usernameLabel = frame:FindFirstChild("UsernameLabel")
	local donatedLabel = frame:FindFirstChild("DonatedLabel")

	if usernameLabel then
		local success, username = pcall(function()
			return Players:GetNameFromUserIdAsync(userId)
		end)
		usernameLabel.Text = success and username or "Unknown"
	end

	if donatedLabel then
		donatedLabel.Text = "💸 " .. commaValue(donated) .. " 💸"
	end
end

-- Rainbow text effect
local function startRainbowEffect(textLabel)
	spawn(function()
		while true do
			for i = 0, 255, 10 do wait(0.05) textLabel.TextColor3 = Color3.new(1, i/255, 0) end
			for i = 255, 0, -10 do wait(0.05) textLabel.TextColor3 = Color3.new(i/255, 1, 0) end
			for i = 0, 255, 10 do wait(0.05) textLabel.TextColor3 = Color3.new(0, 1, i/255) end
			for i = 255, 0, -10 do wait(0.05) textLabel.TextColor3 = Color3.new(0, i/255, 1) end
			for i = 0, 255, 10 do wait(0.05) textLabel.TextColor3 = Color3.new(i/255, 0, 1) end
			for i = 255, 0, -10 do wait(0.05) textLabel.TextColor3 = Color3.new(1, 0, i/255) end
		end
	end)
end

-- Refresh leaderboard
local function refreshLeaderboard()
	_G.refreshLeaderboard = refreshLeaderboard -- make global

	-- Clear old frames
	for _, child in ipairs(PlayerHolder:GetChildren()) do
		if child:IsA("Frame") and child.Name ~= "Sample" then
			child:Destroy()
		end
	end

	-- Get top donations
	local success, data = pcall(function()
		return DonationsDS:GetSortedAsync(false, 10):GetCurrentPage()
	end)

	if not success then
		warn("Failed to get leaderboard data")
		return
	end

	for rank, entry in ipairs(data) do
		local userId = tonumber(entry.key)
		local donated = entry.value
		local username = "Unknown"

		pcall(function()
			username = Players:GetNameFromUserIdAsync(userId)
		end)

		local displayName = username
		local thumbUrl = "https://www.roblox.com/headshot-thumbnail/image?userId="..userId.."&width=48&height=48&format=png"

		local newFrame = Sample:Clone()
		newFrame.Name = "Player_" .. userId
		newFrame.Visible = true
		newFrame.Parent = PlayerHolder

		local profilePic = newFrame:FindFirstChild("ProfilePicture")
		local displayNameLabel = newFrame:FindFirstChild("DisplayName")
		local nameLabel = newFrame:FindFirstChild("Name")
		local donatedLabel = newFrame:FindFirstChild("Donated")

		if profilePic and profilePic:IsA("ImageLabel") then
			profilePic.Image = thumbUrl
		end

		if displayNameLabel and displayNameLabel:IsA("TextLabel") then
			displayNameLabel.Text = displayName
		end

		if nameLabel and nameLabel:IsA("TextLabel") then
			nameLabel.Text = "@"..username
		end

		if donatedLabel and donatedLabel:IsA("TextLabel") then
			donatedLabel.Text = commaValue(donated)
		end

		-- Update statue for top donor
		if rank == 1 then
			setRigAppearance(StatueCharacter, userId)
			updateStatueOverhead(userId, donated)
			if donatedLabel then startRainbowEffect(donatedLabel) end
		end
	end
end

-- Main loop
while true do
	refreshLeaderboard()
	wait(RefreshTime)
end

here is the location of the overhead gui:

I don’t know why it isn’t showing up, if anybody knows how to fix this I would appreciate the help, thanks in advance!

Maybe try having a print statement after each if not condition then return end to see if it’s exiting the function early.

tried prints before and nothing prints

Have you tried printing at the start of the update gui text to see if the functions ever runs?

..Hard to believe that script didn’t work out.
Tested fine for me.. good luck

I made prints all over the function and before it, the function runs until the ends but I don’t why the gui doesn’t appear:

print("beforeUPDstatueOverhead")
-- Update statue overhead display
local function updateStatueOverhead(userId, donated)
	local head = StatueCharacter:FindFirstChild("Head")
	
	if head then
		print("headFound")
	end
	
	if not head then 
		print("headNotFound")
		return 
	end

	local overheadGui = head:FindFirstChild("OverheadGui")
	
	if overheadGui then
		print("GUIFound")
	end
	
	if not overheadGui then
		print("GUInotFOUND")
		return
	end

	local frame = overheadGui:FindFirstChild("Frame")
	
	if overheadGui then
		print("FrameFOUND")
	end

	
	if not frame then
		print("FramenotFOUND")
		return
	end

	local usernameLabel = frame:FindFirstChild("UsernameLabel")
	local donatedLabel = frame:FindFirstChild("DonatedLabel")
	
	if usernameLabel then
		print("UsernameLabelFOUND")
		
	else print("usernamelabelnotfound")	
		
	end
	
	if donatedLabel then
		print("DonatedLabelFOUND")
		
	else print("DonationLabelNotFound")	
		
	end
	
	
	
	if usernameLabel then
		local success, username = pcall(function()
			return Players:GetNameFromUserIdAsync(userId)
		end)
		usernameLabel.Text = success and username or "Unknown"
		print("username set")
	end

	if donatedLabel then
		donatedLabel.Text = "💸 " .. commaValue(donated) .. " 💸"
		print("donated set")
	end
end

It printed that everything is found and set but there was no gui showing up

If you manually change the text properties in studio (without running the game) does the GUI display as expected? If not it may be an issue with the way your GUI is set up.

In studio yeah, it displays as expected

I had in my script where the rig updates and refreshes and thats what was deleting my overheadgui so I made it always clone after the refresh.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.