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

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