I read the wiki page and I did what I understood but it is still not working and I dont know why, it doesn't even print the Name, Strength, And Place When It Is Told To.
Script:
local ds = game:GetService("DataStoreService"):GetDataStore("UserData")
local ods = game:GetService("DataStoreService"):GetOrderedDataStore("GameData")
local Misc = game:GetService("ReplicatedStorage").Misc
local Number = Misc.Number
local StrengthBoard = workspace.StrengthBoard
local StrengthSg = StrengthBoard.Part.sg
local SHolder = StrengthSg.Holder
function UpdateStrengthBoard()
local isAscending = false
local pageSize = 10
local pages = ods:GetSortedAsync(isAscending, pageSize)
local topTen = pages:GetCurrentPage()
for rank, data in ipairs(topTen) do
print("Rank: ".. rank)
print("Name: "..string.sub(data.key,9))
print("Value: "..data.value)
local name = string.sub(data.key,9)
local Strength = data.value
local NClone = Number:Clone()
NClone.PlayerName.Text = name
NClone.PlayerStrength = Strength
if #SHolder:GetChildren() > 0 then
local LastPlace = nil
for i,v in pairs(SHolder:GetChildren()) do
if i == #SHolder:GetChildren() then
LastPlace = v
end
end
local X = LastPlace.Position.X
local RealX = (X+100)+(5*#SHolder:GetChildren())
local RealPos = UDim2.new(RealX,0,0)
NClone.Parent = SHolder
NClone.Position = RealPos
else
NClone.Parent = SHolder
end
end
end
game.Players.PlayerAdded:Connect(function(plr)
local leaderstats = Instance.new("Folder", plr)
leaderstats.Name = "leaderstats"
local Strength = Instance.new("NumberValue", leaderstats)
Strength.Name = "Strength"
local Rebirths = Instance.new("NumberValue", leaderstats)
Rebirths.Name = "Rebirths"
local key = "plr-".. plr.userId
local SavedData = ds:GetAsync(key)
local SKey = "Strength-"..plr.Name
if SavedData then
Strength.Value = SavedData[1]
Rebirths.Value = SavedData[2]
else
local DataToSave = {Strength.Value, Rebirths.Value}
ds:SetAsync(key, DataToSave)
ods:SetAsync(SKey,Strength.Value)
end
end)
game.Players.PlayerRemoving:Connect(function(plr)
local key = "plr-".. plr.userId
local DataToSave = {plr.leaderstats.Strength.Value, plr.leaderstats.Rebirths.Value}
ds:SetAsync(key, DataToSave)
end)
wait(2)
UpdateStrengthBoard()
while wait(60) do
UpdateStrengthBoard()
end
