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

I followed a tutorial (about ordered datastores) but, my code doesn't work! Why doesn't it work?

Asked by 4 years ago
Edited 4 years ago

So, I followed a Tutorial , but my code doesn't work for some reason. (This is my first question on this website and also sorry for bad english) code:

local DataStoreService = game:GetService("DataStoreService")
local PlayerLevelStore = DataStoreService:GetOrderedDataStore("PlayerLevelStore")
-- Put the data in
local PlayerLevels = {
    ["CalledMonk12"] = 61,
    ["SallyWacky"] = 25,
    ["NancyPlays"] = 82,
    ["AwasomeMinecraftYT"] = 11,
    ["Daimian111"] = 111
}
for User, Level in pairs(PlayerLevels) do
    PlayerLevelStore:SetAsync(User, Level)
end
local Pages = PlayerLevelStore:GetSortedAsync(false, 3)
while wait() do
    local Data = Pages:GetCurrentPage()
    for i, v in pairs(Data) do
        print(v.Key)
        print(" - ")
        print(v.Value)
    end
    if Pages.IsFinished() then
        break
    else
        print("---------------------")
        -- Next page
        Pages:AdvanceToNextPageAsync()

    end
end

output:

  nil
  - 
  nil
  nil
   - 
  nil
  nil
   - 
  nil
  04:49:12.055 - ServerScriptService.Script:22: attempt to call a boolean value

More information: Testng style: I use "Run" In roblox studio Script type and location: Script type: Server script Script location: ServerScriptService

0
should "Pages.IsFinished()" be "Pages:IsFinished()"? VAHMPIN 277 — 4y
0
VAHMPIN, oh, thanks, I don't get the error anymore, but it still prints nil. Daimian111 -4 — 4y
0
check my answer. VAHMPIN 277 — 4y
0
It doesn't work, now I get table: 0x3ed243d9ded208e2 intead of the nil Daimian111 -4 — 4y
0
sorry, didn't get notified of the reply. I don't do about data stores, i don't know a lot. VAHMPIN 277 — 4y

1 answer

Log in to vote
0
Answered by
VAHMPIN 277 Moderation Voter
4 years ago
Edited 4 years ago

The error is your code:

22 if Pages.IsFinished() then

should be:

22 if Pages:IsFinished() then

the other error might be

v.Value -- try v on its own
Ad

Answer this question