Leaderstats Script Not Working. Please Help!

Ok, so im testing it and it gives me 2 errors when its supposed to refresh/upload…

Edit: but i do have to say, i still have the other leaderboards in it yet the problem is fixed! just now have to fix this one.

Let me investigate…

leaderboards.rbxm (9.2 KB)

Now? I’m not pretty sure if that resolves the issue, let me know.

sorry was fixing errors in another game from years ago… let me see…

Be sure to remove the old leaderboards, as they seem to cause the issue.

yeah, when i added yours in, it was fixed but i still had the old ones in…

Remove them, the leaderboards I gave to you doesn’t fix the old issue, removing the old leaderboards might potentially solve the issue.

i know, i do think i know why its “Fixed” though, theres a random error but i willl delete them

Remember that you can undo by pressing CTRL + Z if that didn’t fix the problem.

oh and yours is still giving an error, i dont put the scripts in anything, do i?

No, the model comes ready with itself.

Can you show me the error?..

I haven’t tested it on my studio, because I don’t really want to set up a datastore leaderstats service.


same error…!

Not every error is the same…
By the way, print the keys by typing this at line 56

print(v.key)

Oh maybe the previous saved data is interrupting the system, I’ll add safety checks to that.

leaderboards.rbxm (9.2 KB)

1 Like

When everyone has joined and left again it should be safe to work again. But the safety checks are there just in case.

the coin one worked, the orb leaderboard did nothing.

No error was given…

but since the leaderstats is working now… uhm… idk lol

Wait, you might want to reset the leaderstats that save data for leaderboards. Just so it “works” better.
(Btw I mean the boards, not the global stats)

local saves = {"Orbs", "Coins"}

local dss = game:GetService("DataStoreService")

for i, save in ipairs(saves) do
	local ods = dss:GetOrderedDataStore(save)
	
	local pages = ods:GetSortedAsync(false, 10)
	local currentPage = pages:GetCurrentPage()
	
	while true do
		for i, v in ipairs(currentPage) do
			if v.key and v.value then
				local s, err = pcall(function()
					ods:RemoveAsync(v.key)
				end)
				print(((s and "Success") or "Failed") .. " to delete " .. tostring(v.key) .. " from " .. tostring(save))
			end
		end
		if pages.IsFinished then break end
		pages:AdvanceToNextPageAsync()
		currentPage = pages:GetCurrentPage()
		print("Looped to next page")
		wait()
	end
end
print("Finished clearing OrderedDataStores with saves list")

Just execute this in the command bar and watch output, if it says “Finished clearing…” then it’s done.

Alternatively: Put it in a script, and run the game once, stop the game after it has finished, and then delete the script / disable it.