Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why isnt GetOrderedDataStore working for my global leaderboards gui?

Asked by 3 years ago
Edited 3 years ago

I been using the same datastore for quite sometime with my game and decided to add a global leaderboard but this script wont return or do anything, i cant figure out the problem.

local dst_nades = game:GetService("DataStoreService"):GetOrderedDataStore('Shrek_exe Nades')

local Players = game:GetService("Players")
local Global = script.Parent:WaitForChild("Global_Leaderstats")

function Leadertext(Place,Username,Nades)
    return ('#'..Place..' '..Username..' | Shreknades: '..Nades)
end
function GetAvatarImage(Id)
    return Players:GetUserThumbnailAsync(Id, Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size420x420)
end
function GlobalLeaderstats()
    local sorted = dst_nades:GetSortedAsync(false, 10, 1, math.huge)
    local current = sorted:GetCurrentPage()
    for rank, data in pairs(current) do
        local Inst = Global["#"..rank]
        local UserId = data.key:match('%d+') -- (Original: "Player_012345")
        local Username = Players:GetNameFromUserIdAsync(UserId)
        local Avatar = GetAvatarImage(UserId)
        local TextLabel = Inst.TextLabel
        TextLabel.Parent.Image = Avatar
        TextLabel.Text = Leadertext(tonumber(rank), tostring(Username), tonumber(data.value))
    end
end

GlobalLeaderstats();
while wait(30.0) do 
    GlobalLeaderstats()
end

Image of explorer: https://gyazo.com/108134e4d5754c598cd40c6d154e982b

0
Are you getting any errors? What are your values? iOwn_You 543 — 3y
0
@IOwn_You there are no errors and wym by "values" BurgerKingHappy_Meal 25 — 3y
0
I mean what are you trying to save into the datastore? iOwn_You 543 — 3y
0
@IOwn_You Thrown grenades leaderstat (Numbers) BurgerKingHappy_Meal 25 — 3y
View all comments (2 more)
0
maybe its because you did 'GlobalLeaderstats();' at line 26 and not at line 28. you forgot the ; NoobPowerPlayzz 15 — 3y
0
@NoobPowerPlayzz Didn't work even with or without the ";". BurgerKingHappy_Meal 25 — 3y

1 answer

Log in to vote
0
Answered by 3 years ago

Figured out that i was using GetDataStore instead of GetOrderedDataStore for saving player data...

Ad

Answer this question