Help with leaderboard script

  1. What do you want to achieve? i want to fix my leaderboard script

  2. What is the issue? it isnt working, there are no errors and it’s saying that “it got updated”

  3. What solutions have you tried so far? look twice through the script

!

local StudsLeaderboard = DataStoreService:GetOrderedDataStore("StudsLeaderboard")

local function updateLeaderboard()
	local success, errorMessage = pcall(function()
		local Data = StudsLeaderboard:GetSortedAsync(false, 5)
		local StudsPage = Data:GetCurrentPage ()
		for Rank, data in ipairs(StudsPage) do
			local userName = game.Players:GetNameFromUserIDAsync(tonumber(data.key))
			local Name = userName
			local Studs = data.value
			local isOnLeaderboard = false
			for i, v in pairs(game.Workspace.GlobalLeaderboard.LeaderboardGUI.Holder:GetChildren()) do
				if v.Player.Text == Name then
					isOnLeaderboard = true
					break
				end
			end
			if Studs and isOnLeaderboard == false then
				local newLBFrame = game.ReplicatedStorage:WaitForChild("LeaderboardFrame"):Clone()
				newLBFrame.Player.Text = Name
				newLBFrame.Studs.Text = Studs
				newLBFrame.Rank.Text = "#"..Rank
				newLBFrame.Position = UDim2.new(0, 0, newLBFrame.Position.Y.Scale + (.08 * #game.Workspace.GlobalLeaderboard.LeaderboardGUI.Holder:GetChildren()), 0)
				newLBFrame.Parent = game.Workspace.GlobalLeaderboard.LeaderboardGUI.Holder
			end
		end
	end)
	
	if not success then
		print(errorMessage)
	end
end

while true do
	
	for _, player in pairs(game.Players:GetPlayers()) do
		StudsLeaderboard:GetAsync(player.UserId, player.leaderstats.Studs.Value)
	end
	
	for _, frame in pairs(game.Workspace.GlobalLeaderboard.LeaderboardGUI.Holder:GetChildren())do
		frame:Destroy()
	end
	
	updateLeaderboard()
	print("Updated!")
	
	wait(50)
end```

there is no errors because there is a pcall(function() which makes the script continue even if there is errors you can remove it just to check if there is errors.

other than my body parts not loading, still no errors

did you remove the pcall(function()?

1 Like

yes, i did remove the function

nevermind, there might be a problem with roblox servers, because the API services are apparently forbidden

however i am no scripter, can you confirm this?

enable api in studio under game settings then security. make sure to publish

1 Like

i totally forgot to mention that lol.

already did that

ccccccharrrrrrr