Hello roblox community, this is a Global Leaderboard script, I get an error on line 35:
‘PointsLeaderboard:SetAsync(player.UserId,currency)’
but I have tried all the ways and it doesn’t work, please.
Script, “ServerScriptService”:
local DataStore = game:GetService('DataStoreService')
local PointsLeaderboard = DataStore:GetOrderedDataStore('JuanesTeban')
local function updatePointsLeaderboard()
local succes, errorMessage = pcall(function()
local Data = PointsLeaderboard:GetSortedAsync(false,5)
local WinsPage = Data:GetCurrentPage()
for Rank, data in pairs(WinsPage) do
local UserName = game.Players:GetNameFromUserIdAsync(tonumber(data.key))
local Name = UserName
local Points = data.Value
local isOnLeaderboard = false
for i,v in pairs(game:GetService('Workspace').TopLeaderstatsPoints.TopLeaderboard:GetChildren()) do
if v.TOPPOINTS.Visible == true then
isOnLeaderboard = true
break
end
end
if Points and isOnLeaderboard == false then
local ListaJugadoresClone = game:GetService('ReplicatedStorage'):WaitForChild('ListaJugadores'):Clone()
ListaJugadoresClone.Jugador.Text = Name
ListaJugadoresClone.POINTS.Text = Points
ListaJugadoresClone.Puesto.Text = Rank
ListaJugadoresClone.Parent = game:GetService('Workspace').TopLeaderstatsPoints.Scrolling
end
end
end)
if not succes then
print(errorMessage)
end
end
while true do
for _,player in pairs(game.Players:GetPlayers()) do
local currency = player.leaderstats.Points.Value
PointsLeaderboard:SetAsync(player.UserId,currency)
end
updatePointsLeaderboard()
wait(5)
end
There is no description about the error? Usually they should have a description as to why it was not working. either incorrect syntax or missing arguments
Ok, I tried to solve it but I get a problem and it is in line 29 = ‘print(errorMessage)’
local DataStore = game:GetService('DataStoreService')
local PointsLeaderboard = DataStore:GetOrderedDataStore('JuanesTeban')
local function updatePointsLeaderboard()
local succes, errorMessage = pcall(function()
local Data = PointsLeaderboard:GetSortedAsync(false,5)
local WinsPage = Data:GetCurrentPage()
for Rank, data in pairs(WinsPage) do
local UserName = game.Players:GetNameFromUserIdAsync(tonumber(data.key))
local Name = UserName
local Points = data.Value
local isOnLeaderboard = false
for i,v in pairs(game:GetService('Workspace').TopLeaderstatsPoints.TopLeaderboard:GetChildren()) do
if v.TOPPOINTS.Visible == true then
isOnLeaderboard = true
break
end
end
if Points and isOnLeaderboard == false then
local ListaJugadoresClone = game:GetService('ReplicatedStorage'):WaitForChild('ListaJugadores'):Clone()
ListaJugadoresClone.Jugador.Text = Name
ListaJugadoresClone.POINTS.Text = Points
ListaJugadoresClone.Puesto.Text = Rank
ListaJugadoresClone.Parent = game.Workspace.TopLeaderstatsPoints.Scrolling
end
end
end)
if not succes then
print(errorMessage)
end
end
while true do
for _,player in pairs(game.Players:GetPlayers()) do
local currency = player.leaderstats.Points.Value
PointsLeaderboard:SetAsync(player.UserId,currency)
end
updatePointsLeaderboard()
wait(5)
end
your print(errorMessage) is not the problem. It’s simply printing the error (script not being able to find TOPPOINTS in the hierarchy you placed on the script)