I have been trying to script a data store but this is my first time using ordered data stores usually I use normal ones. And I am getting an error that says "Array is not allowed in data stores"
Ive never had this error before but again Ive never used ordered data stores before so.
Heres my code. The error is on line 55.
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local DataStoreService = game:GetService("DataStoreService")
function LoadData(Player)
local DataFolder = Instance.new("Folder")
DataFolder.Name = Player.UserId
DataFolder.Parent = ReplicatedStorage:WaitForChild("DataFolder")
local DataStore = DataStoreService:GetOrderedDataStore(Player.UserId)
local DataPages = DataStore:GetSortedAsync(false, 100)
local Data = DataPages:GetCurrentPage()
for Index, Object in pairs(Data) do
print(Object.Key, Object.Value)
end
-- if Data.IsFinished == false then
-- Data:AdvanceToNextPageAsync()
-- end
end
function SaveData(Player)
local DataToSave = {}
for Index, Object in pairs(ReplicatedStorage.DataFolder[Player.UserId]:GetDescendants()) do
if Object:IsA("IntValue") or Object:IsA("NumberValue") or Object:IsA("StringValue") or Object:IsA("BoolValue") then
table.insert(DataToSave, Object.Value)
end
end
local DataStore = DataStoreService:GetOrderedDataStore(Player.UserId)
DataStore:SetAsync(Player.UserId, DataToSave)
end
Players.PlayerAdded:Connect(LoadData)
Players.PlayerRemoving:Connect(SaveData)
Thank you for your time and hopefully we can figure this out because data saving is important XD

2 comments
I would accept this answer its just I am trying to use ordered data stores instead of the normal ones because of something I am doing.
are you making a Global Leaderboard?