Leaderboard script

i cant see it under home (30char)
got it
edit its off

You have to enable it and then this current error should disappear.

yae it did so does the leaderboard work know ?

Give it a try, I haven’t really looked further than that

it shows this now will the nil be money in the servers

No, that shouldn’t be nil, give me like a few minutes, to copy this entire thing into my place and test it myself

Okay so I’ve copied this into my script and it seems to be working @rohanspeeltgames

local DataStore = game:GetService("DataStoreService"):GetOrderedDataStore("MoneyX1")

for i = 1,10 do
    local Sam = script.Sample:Clone()
    Sam.Name = i
    Sam.Parent = script.Parent.SurfaceGui.Frame.ScrollingFrame
    Sam.UserPos.Text = "[".. tostring(i) .. "]"
    Sam.Money.Text = "Nil"
    Sam.UserName.Text = ""
    Sam.LayoutOrder = i
    script.Parent.SurfaceGui.Frame.ScrollingFrame.CanvasSize = UDim2.new(0,0,0,50*i)
end

function UpdateGui()
	
	for i,v in pairs(game.Players:GetChildren()) do
		local Data = 1
		DataStore:SetAsync(v.UserId, Data)
	end
	
	local Pages = DataStore:GetSortedAsync(false,10)
	local Data = Pages:GetCurrentPage()
	
	for k,v in pairs(Data) do
		if tonumber(v.key) >= 1 then
			local Frame = script.Parent.SurfaceGui.Frame.ScrollingFrame:FindFirstChild(tostring(k))
			if Frame then
				Frame.UserName.Text = game.Players:GetNameFromUserIdAsync(v.key)
				Frame.Money.Text = tostring(v.value)
			end
		end
	end

end

while true do 
    UpdateGui()
    wait(60)
end

What I’ve changed is:

  • Moved variable DataStore to the top of the code and renamed it from DateStore to DataStore because I’m not sure if roblox would consider that as something that’s not allowed
  • Replaced tostring(v.Value) with tostring(v.value)
  • Increased the amount of time between each update

And here’s the result

i cant test it right now becose there are people in my server and if i shutdown the server there is an chance that they lose stats

what is the 1 for on the right side

The 1 on the side is how much he has.

it is in my game to but i got like 200N

If that’s the right value, then it’s working

my value is Money so why isnt it working

Would you mind sending me your current script to see which value you are displaying?

or do i need to put m ?

local m = Instance.new("StringValue", stats)

m.Name = "Money"

m.Value = 5

I mean your leaderboard script

oww wait does my script need to be called leaderboard ?

Oh no, the name doesn’t affect anything, it can be called however you want

idk what to use
local m = Instance.new(“StringValue”, stats)

m.Name = “Money”

m.Value = 5

local money = Instance.new(“NumberValue”, stats)

money.Name = “Cash”

money.Value = 1

do i need to use Money or Cash