Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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

5 comments

0

should "Pages.IsFinished()" be "Pages:IsFinished()"?

0

VAHMPIN, oh, thanks, I don't get the error anymore, but it still prints nil.

0

check my answer.

0

It doesn't work, now I get table: 0x3ed243d9ded208e2 intead of the nil

0

sorry, didn't get notified of the reply. I don't do about data stores, i don't know a lot.

1 answer

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

This discussion is preserved as it was. New answers, comments, and votes are closed.