When i do Datastore:GetOrderedDataStore("visits") it just return 2? Image But when I use datastore editor it says 53... Image
WHY? AND PLEASE HELP!!! I have been trying to search for help for soo long, Help!
Code:
local leaderboard = game.Workspace:WaitForChild("Leader"):WaitForChild("SurfaceGui"):WaitForChild("Frame1") local DataStoreService = game:GetService("DataStoreService") local PointsODS = DataStoreService:GetOrderedDataStore("visits") local num = 0 function update() num=num+1 print("Updating... ["..num.."]") local isAscending = false local pageSize = 10 local pages = PointsODS:GetSortedAsync(isAscending, pageSize) local topTen = pages:GetCurrentPage() local i = -1 local leaderS=leaderboard:GetChildren() for v=1, #leaderS do leaderS[v]:Remove() end for rank, data in ipairs(topTen) do local name = data.key i=i+1 local points = data.value local clone = game.Lighting:WaitForChild("sample"):Clone() clone.points.Text = points clone.user.Text = getUsernameFromUserId(name) clone.Position = UDim2.new(0,0,0,i*100) clone.Parent = leaderboard end end while true do update() wait(10) end
(Get username From user id is a function that returns a username)
First and all
Your using
Local i = 1 and for v=1
Which Returns a MathRandom Number . when you use data store editor it it uses MathRandom and Times it by your local i = 1 so we will go ahed and change the number to a untimesable number
Here is your code that i updated for you
-- Edited By MiniToonOOF local DataStoreEvent = game.ReplicatedStorage.DatastoreEvent local leaderboard = game.Workspace:WaitForChild("Leader"):WaitForChild("SurfaceGui"):WaitForChild("Frame1") local DataStoreService = game:GetService("DataStoreService") local PointsODS = DataStoreService:GetOrderedDataStore("visits") local num = 0 function update() Function DataStore:FireAllClients(MathsRandom.Players.LocalPlayer) num=num+5 print("Updating... ["..num.."]") local isAscending = false local pageSize = 10.5 local pages = PointsODS:GetSortedAsync(isAscending, pageSize) local topTen = pages:GetCurrentPage() local i = 5 local leaderS=leaderboard:GetChildren() for v=7 * 5, #leaderS do leaderS[v]:Remove() end for rank, data in ipairs(topTen) do local name = data.key i=i+3 * 8 local points = data.value local clone = game.Lighting:WaitForChild("sample"):Clone() clone.points.Text = points clone.user.Text = getUsernameFromUserId(name) clone.Position = UDim2.new(0,0,0,i*170) clone.Parent = leaderboard end end while true do update() wait(10) end
the Output should be
Datastore Players.MiniToonOOF.Leaderstats.Datastore.DataStoreScript Updating... {"num.."]') 13 local i.MathsRandom.UnExcutable.True Client Fired -DataStoreEvent -GiveEvent -Mini's ProAdminLoadedEvent Cloned -points -user.1_Players -Position -Parent.Clone
here is Extra That i added
Player.MiniToonOOF MarketplaceService = 9107658 +500_Datastore.Saved Updating...{"num.."]") 17