103: Array is not allowed in data stores [Solved!]

It is for retrieving OrderedDataStores, which have a GetSortedAsync function, which returns a DataStorePages object, in accesnding or descending order (depending on what you define), inherits from GlobalDataStore and uses all the functions from it with the additional GetSortedAsync function, and values stored in it must be positive integers.

You can use it to make a global leaderboard of the richest players in your game.

Ah, so it’s good for getting the extremes sorted.

Good to know, thank you. :slight_smile:

1 Like

you can explicitly define a table a that holds all of the CFrame values and that would be considered valid and then when u convert it u just plug in the values also when u printed the data after encoding it, all u did was reprint data not the encoded form

local dataStoreService = game:GetService("DataStoreService")
local dataStore = dataStoreService:GetDataStore("Idk")

game.Players.PlayerAdded:Connect(function(plr)
	local key = "key-"..plr.UserId
	
	local data
	
	pcall(function()
		data = dataStore:GetAsync(key)
	end)
		
	print(data)
	
	if data then
		print("Before JSON Decode: "..data)
		local decoded = game:GetService("HttpService"):JSONDecode(data)
		print("After JSON Decode: "..data)
	end
end)

game.Players.PlayerRemoving:Connect(function(plr)
	local key = "key-"..plr.UserId
	
	local data = workspace:WaitForChild("BasePlate").CFrame
	
	data = {
		x = data.x,
		y = data.y,
		z = data.z
	}
	
	local encoded = game:GetService("HttpService"):JSONEncode(data)
	
	print(encoded)
	
	pcall(function()
		dataStore:SetAsync(key, encoded)
	end)
end)
1 Like

You can store tables in data stores, so the JSONEncode and JSONDecode is unnecessary. Also, I would consider doing

local success, err = pcall(function()
	...
end)

And check if there request is successful when testing, the first argument is weather it was successful or not, if it was not successful, the second argument is the error message

Edit: If the request errors, you might put the default data to make sure your game does not break, if you do this, make sure you don’t save the data if the data request was unsuccessful. This mistake can lead to data loss, as the players data is still there but was failed to be retrieved, I would also notify the player that their data failed to load, using GUI, and also put retries in if the first attempt fails.

This is true unless you use compression algorithms like gzip and store a gzipped version of the data.
What I usually do is make simple file formats for simple data, like colors and such.
Takes more time to read and write but is tiny in comparison. Storing RGB for example as {255,255,255} takes up like 13 characters, meanwhile, ÿÿÿ (255 as integer in binary) is 3 characters in size

Data stores in roblox allow tables, and I have stored tables in data stores myself, so I don’t see any problems with storing tables in data stores, also, the encrypted data store is the exactly the same as using HttpService:JSONEncode(), data stores do it internally, so I don’t really see a point in using JSONEncode twice

When again, storing a string or trying to compress the JSON, thats what I meant

1 Like

Thank you!!! Roblox Script auto correction filled my GetD to GetOrdered.

The issue isnt storing tables its storing datatypes, so im giving an option to store unsupported datatypes