Ok so I’ve watched and looked at some tutorials on global leaderboard and they aren’t working for me. Could somebody help me with this? Also, this is 1 of the scripts
while true do
while true do
for _, player in pairs(game.Players:GetPlayers()) do
WinsLeaderboard:SetAsync(player.UserId, player.leaderstats.Wins.Value)
end
for _, frame in pairs (game.Workspace.GlobalLeaderboard.LeaderboardGUI.Holder:GetChildren()) do
frame:Destroy()
end
updateLeaderboard()
print(“Updated!”)
wait(10)
end
In the output, it says string is not allowed in datastore. Please Help.
while true do
for _, player in pairs(game.Players:GetPlayers()) do
WinsLeaderboard:SetAsync(player.UserId, player.leaderstats.Wins.Value)
end
Some Issues Here:
Your While Loop has no Wait()
Your datastore request isn’t wrapped in a pcall function
Your For loop has no end statement
I suggest you decrease the times this data is saved to times when it is important (server shutdown, players leaving, etc). Then wrap your datastore in a pcall shown below. And add the end statement for your for loop.
A tutorial that I found helpful is this . This video is great and straight to the point. As for your script, there are many problems as @xZylter has stated.
Yes, also ive double checked the entire script with the video its the same. The error is “string is not allowed in datastore” as I’ve said before. This is the part with the error “WinsLeaderboard:SetAsync(player.UserId, player.leaderstats.Wins.Value)”
local DataStoreService = game:GetService("DataStoreService")
local PointsODS = DataStoreService:GetOrderedDataStore("Points")
local function printTopTenPlayers()
local isAscending = false
local pageSize = 10
local pages = PointsODS:GetSortedAsync(isAscending, pageSize)
local topTen = pages:GetCurrentPage()
-- The data in 'topTen' is stored with the index being the index on the page
-- For each item, 'data.key' is the key in the OrderedDataStore and 'data.value' is the value
for rank, data in ipairs(topTen) do
local name = data.key
local points = data.value
print(data.key .. " is ranked #" .. rank .. " with " .. data.value .. "points")
end
-- Potentially load the next page...
--pages:AdvanceToNextPageAsync()
end
-- Create some data
PointsODS:SetAsync("Alex", 55)
PointsODS:SetAsync("Charley", 32)
PointsODS:SetAsync("Sydney", 68)
-- Display the top ten players
printTopTenPlayers()