My leaderboard script doesnt work and i dont know why should i remove the abbreviate script? NO ERRORS

local suffixes = {
	K = 4,
	M = 7,
	B = 10,
	T = 13,
	Qa = 16,
	Q = 19,
	S = 22, 
	Sp = 25,
	O = 28,
	N = 31,
	D = 34,
	U = 37,
	Du = 40,
	Tr = 43,
	Qd = 46,
	Qid = 49,
	Sd = 52,
	Spd = 55,
	Oc = 58,
	No = 61,
	V = 64,
	Uv = 67,
	Dv = 70,
	Tv = 73,
	Qv = 76,
	Qi = 79,}
local function format(val)
	for i=1, #suffixes do
		if tonumber(val) < 10^(i*3) then
			return math.floor(val/((10^((i-1)*3))/100))/(100)..suffixes[i]
		end
	end	
end

local dataStoreService = game:GetService("DataStoreService")
local players = game:GetService("Players")

local globalDataStore = dataStoreService:GetOrderedDataStore("NormallsSlots")
local board = workspace.Leaderboards.CoinsLb.Handler.lbGUI

local template = game.ReplicatedStorage.Gui.lbFrame:Clone()
board.Holder.Scroll:WaitForChild("lbFrame"):Destroy()

local function update()

	for _,child in pairs(board.Holder.Scroll:GetChildren()) do

		if child:IsA("Frame") then

			child:Destroy()

		end
	end

	local success,err = pcall(function()

		local data = globalDataStore:GetSortedAsync(false,40)
		local page = data:GetCurrentPage()

		for rank,plrData in ipairs(page) do
			

			local userid = plrData.key
			local stats = plrData.Value

			if rank < 1 then

				local npc = workspace.Leaderboards.CoinsLb.Statue:FindFirstChild(rank)

				if npc then

					npc.UserId.Value = userid

				end

			end

			local new = template:Clone()
			new.Player.Text = players:GetNameFromUserIdAsync(userid)
			new.Stats.Text = format(stats)
			new.Rank.Test = "#"..rank
			new.LayoutOrder = rank
            new.Parent = board.Holder.Scroll
		end
	end)
end

while true do

	update()

	wait(math.random(10,30))

	spawn(function()

		for _,plr in pairs(game.Players:GetPlayers()) do

			globalDataStore:SetAsync(plr.UserId,plr.leaderstats.Coins.Value)
			wait()

		end

	end)

end

3 comments

0

You need to be more descriptive. You can't say "it doesn't work" and post 100 lines of code with no further information.

0

Like @Optikk said you HAVE to be more DESCRIPTIVE when posting questions so that the community will be well-equipped to help with your enquiry/inquiry. If you want to learn how to post good question/answers, then visit HERE: https://scriptinghelpers.org/help/how-post-good-questions-answers

0

Its common sense, if you want us to help you, you have to help us by being descriptive and by following the rules. Regardless of that, your question is closed because it doesn't follow the rules and regulations!