this is a global leaderboard script, it works if there's one of them but it doesn't when I have multiple. it gives me a error of "Unable to cast string to int64", and supposedly the error happens on line 38
local datastore = game:GetService("DataStoreService") local players = game:GetService("Players") local globalstore = datastore:GetOrderedDataStore("globalgold1") local board = workspace.GoldBoard.Part local temp = board.SurfaceGui.ScrollingFrame.Frame:Clone() board.SurfaceGui.ScrollingFrame.Frame:Destroy() local function update() for _,child in pairs (board.SurfaceGui.ScrollingFrame:GetChildren()) do if child:IsA("Frame") then child:Destroy() end end local suc, err = pcall(function() local data = globalstore:GetSortedAsync(false,30) local page = data:GetCurrentPage() for rank,plrData in ipairs(page) do local name = plrData.key local money = plrData.value if rank ==1 then local npc = workspace:FindFirstChild("2") if npc then npc.UserId.Value = name end end local new = temp:Clone() new.PlrName.Text = players:GetNameFromUserIdAsync(name) new.Stat.Text = money new.LayoutOrder = rank new.Parent = board.SurfaceGui.ScrollingFrame end end) end while true do update() wait(180) spawn(function() for _,plr in pairs (game.Players:GetPlayers()) do globalstore:SetAsync(plr.UserId,plr.leaderstats.Gold.Value) wait(180) end end) end
I believe that the name variable is a string. Try doing this on line 38 instead.
new.PlrName.Text = players:GetNameFromUserIdAsync(tonumber(name))