Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
2

Why is Datastore returning 2?

Asked by 4 years ago
Edited 4 years ago

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)

0
You know we can't help you without seeing your code right? Nanomatics 1160 — 4y
0
Updating question... ParentProfanities 28 — 4y
0
Updated ParentProfanities 28 — 4y
0
sounds like you made a movie "Why is Datastore returning 2?: Datastore revenge" MagicPineappleLOLKA -6 — 4y
0
How are you setting the value on the DataStore? Is your game allowed to save DataStore data in Roblox Studio? MacaylaMarvelous81 15 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

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
Ad

Answer this question