Leaderboard classification script not working

I was making a table of classifications but something is failing I want it to be of levels but when they change the name it fails again. I need someone to help me, I leave some screenshots

.

2-


here’s the script of the other problem.
local OrderedDataStore = game:GetService(“DataStoreService”):GetOrderedDataStore(“Saved”)

local Holder = script.Parent.Frame.ScrollingFrame

local CurrencyName = “Levels”
local Prefix = "Levels "

local List = 15
local RefreshingTime = 10

function Main ()
local Success, Error = pcall(function()
local Pages = OrderedDataStore:GetSortedAsync(false, List)
local Data = Pages:GetCurrentPage()

    for pos, v in ipairs(Data)do
        local PlayerName = tostring(v.key)
        local Data = tostring(v.value)
        local NewFrame = script.Frame:Clone()
           
        NewFrame.PlayerPos.Text = pos .. ". " .. PlayerName
        NewFrame.PlayerCurrency.Text = Prefix .. Data
        NewFrame.Parent = Holder
    end
end)
if not Success and Error then
    error(Error)
end

end

while true do
for _, Player in pairs(game.Players:GetPlayers())do
local PlayerValue = Player.leaderstats[CurrencyName]

    OrderedDataStore:SetAsync(Player.Name, PlayerValue.Value)
end
for _, v in pairs(Holder:GetChildren())do
    if v.Name == "Frame" and v:IsA("Frame") then
        v:Destroy()
    end
end
Main()
wait(RefreshingTime)

end

Okay. So for the screenshots, ‘Parent’ is not a variable, so it will not work. Just change it to:

local level = Instance.new(‘IntValue’)
level.Name = ‘level’

As for leaderstats, just make it leader. That is what you named the function after all!

tomorrow I will try…

1 Like

it doesn’t work for me =,(…

function leader(Player)
local Folder = Instance.new(‘Folder’)
Folder.Name = ‘leaderstats’
Folder.Parent = Player

local level = Instance.new(‘IntValue’)
level.Name = ‘level’
level.Value = 1
level.Parent = Folder
end

game.Players.PlayerAdded:Connect(leader)

That should be your whole working script. I hate to give out code, but there are a lot of errors here.

aside from what @AlsoGold said,

image

Conent is not a function, in fact I don’t think it’s anything at all.
Secondly what on Earth are you doing with game.Parent ?
to run a function each time a player joins
do this instead :

local Players = game:GetService("Players")
  Players.PlayerAdded:Connect(function()
 --// code
end)

also you can’t connect an event to a non-existent function , you can’t connect it to an instance either (like leaderstats), that doesn’t make sense!

As for

one problem a thread please.

2 Likes

I’m sorry to tell you that it doesn’t work for me (I’m going to see some toturials)

What doesn’t work exactly? Can you be more specific? The code @AlsoGold seems to be fine. Can you show any errors you’re facing?