local short = {"", "K", "M", "B", "T"} -- Add more
local function abbrievateNum(number)
local str = tostring(math.floor(number))
return string.sub(str, 1, ((#str-1)%3) + 1)..short[tonumber((#str-1)/3) +1)]
end
I hope that works.
local short = {"", "K", "M", "B", "T"} -- Add more
local function abbrievateNum(number)
local str = tostring(math.floor(number))
return string.sub(str, 1, ((#str-1)%3) + 1)..short[tonumber((#str-1)/3) +1)]
end
I hope that works.
So you’re gonna mark me as a solution ? Yessss!
ty, that is quite a complex but short script. very well thought out.
yeah of course thanks for your help!
It’s simple actually, I’ll explain you in some time on your DM if you wish!
yes thanks. the only problem is that I gtg so I will check your messages tommorow ok? (I’m dutch btw)
does my ping also effect the global leaderboard?
Nope, it doesn’t. It doesn’t affect client-sided.
@Moneypro456789 the global leaderboard has this issue when 30 players are visible on the global leaderboard: Players:GetNameFromUserIdAsync() failed: HTTP 429 (Too Many Requests). thats why its not working and when I change the time it doesn’t really affect it.
Oh, so try to lower the requests. Send me your latest code.
I am working on a system that just stops when the request is full and continues when it is possible again.
how can lower my requests? because it needs to get all of the names and every name is a request.
but to be fair, the way I use it now works and adapts exactly to the waiting times. the disadvantage is that if the requests are full it also takes 30 seconds before it continues. lowering my requests will probably fix it.
I just do this
while wait(0.0001) do
local suc, err = pcall(function()
local Username = game.Players:GetNameFromUserIdAsync(tonumber(SavedData.key))
end)
if suc then
break
end
end
and this
--enable2 is true when 75 samples are loaded in
if enable2 == true then
for i, Frame in pairs(MainFrame.SurfaceGui.ScrollingFrame:GetChildren()) do
if Frame.Name ~= "Sample" and Frame:IsA("Frame") then
Frame:Destroy()
end
enable2 = false
end
and then the samples are loading in again @Moneypro456789
Please send me the code so I could check it.
okay
local DataStoreService = game:GetService("DataStoreService")
local DataStore = DataStoreService:GetOrderedDataStore("YumsSave2")
local MainFrame = script.Parent.Parent
local RefreshRate = 40
local num = 0
local function RefreshLeaderboard()
for i, Player in pairs(game.Players:GetChildren()) do
DataStore:SetAsync(Player.UserId, Player.leaderstats.Yums.Value)
end
local success, Error = pcall(function()
local success2, Error2 = pcall(function()
local Data = DataStore:GetSortedAsync(false, 77)
local CreditsPage = Data:GetCurrentPage()
end)
if Error2 then
RefreshLeaderboard()
end
local Data = DataStore:GetSortedAsync(false, 75)
local CreditsPage = Data:GetCurrentPage()
for Rank, SavedData in ipairs(CreditsPage) do
local Username
if tonumber(SavedData.key) >= 0 then
while wait(0.0001) do
local suc, err = pcall(function()
Username = game.Players:GetNameFromUserIdAsync(tonumber(SavedData.key))
end)
if suc then
break
else
warn(err)
end
end
local Credits = SavedData.value
--warn(Username)
if Credits and not script.Parent:FindFirstChild(Username) then
local NewSample = script.Sample:Clone()
for i,v in pairs(script.Parent.ScrollingFrame:GetChildren()) do
if v.Name ~= 'UI' then
num += 1
end
end
NewSample.Visible = true
NewSample.Parent = MainFrame.SurfaceGui.ScrollingFrame
NewSample.Name = Username
NewSample.PName.Text = Username
if Credits <= 1000 then
NewSample.Value.Text = Credits.." Yums"
else
if Credits >= 1000 and Credits <= 1000000 then
local num = math.floor(Credits / 1000)
local deci = math.floor(Credits - (num * 1000))
NewSample.Value.Text = (num .."."..math.floor(deci / 100).."K Yums")
else
if Credits >= 1000000 and Credits <= 1000000000 then
local num = math.floor(Credits / 1000000)
local deci = math.floor(Credits - (num * 1000000))
NewSample.Value.Text = (num .."."..math.floor(deci / 100000).."M Yums")
else
if Credits >= 1000000000 and Credits <= 1000000000000 then
local num = math.floor(Credits / 1000000000)
local deci = math.floor(Credits - (num * 1000000000))
NewSample.Value.Text = (num .."."..math.floor(deci / 100000000).."B Yums")
else
if Credits >= 1000000000000 then
local num = math.floor(Credits / 1000000000000)
local deci = math.floor(Credits - (num * 1000000000000))
NewSample.Value.Text = (num .."."..math.floor(deci / 100000000000).."T Yums")
end
end
end
end
end
NewSample.Rank.Text = "#"..num + 1
num = 0
else
end
else
end
end
end)
end
local suc, err = pcall(function()
RefreshLeaderboard()
end)
if err then
print(err)
end
while true do
for i, Frame in pairs(MainFrame.SurfaceGui.ScrollingFrame:GetChildren()) do
if Frame.Name ~= "Sample" and Frame:IsA("Frame") then
Frame:Destroy()
end
end
RefreshLeaderboard()
Rank2 = 1
wait(RefreshRate)
end
this is how it is rn @Moneypro456789
this doesn’t work btw. could you perhaps incorporate it into my code and then send it to me?
it is also not completely closed (the parentheses).
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.