So I’m programming a game, and you basically go on a tile to claim it if you have enough points. Each tile will reveal an item to gain more points. The thing is, when I’m trying to save the tiles, problems start to rise. Because these tiles are not on a grid, I decided to save all of the objects in a table. Unfortunately, you cannot save tables, dictionaries, and objects. The easy way around this is by using :JSONEncode which encodes the input into a string that will later be decoded when you get the data. The problem with that is that you cannot encode objects. I cannot really find a way around this. Do any of you know how I can solve this problem?
Why don’t you save the tiles as a grid?
You can save tables - they just can’t be mixed, for objects you can just write a method to serialize it into a table, with the necessary unique properties and have an additional constructor that creates the object with the serialized data.
Did you mean instances or objects?
I meant Instances but also if you have values and then a table inside the table does it count as being a mix?
It’s only considered mixed if any table isn’t only an array or dictionary, and yes you can save nested tables.
whats the difference with array and a table cause i just assumed it was the same as a table
you can also store it as a dictionary like
parts = {{x = 69, y = 420},{x = 42, y = 69}}
You can save them in multiple ways. Probably the easiest would be to create some kind of grid that represents each plot. Otherwise, if you were lazier you could probably save it as a dictionary with the name of each being the CFrame of each plot or something. You’d probably need to understand some string formatting though.
Arrays in Lua are essentially just tables, where you index the table with an integer:
https://www.lua.org/pil/11.1.html
also array has only integer as the index while dictionary is usually a string
an array is a 1D table full of numbers
a matrix is a 2D array
even 3D and 4D arrays exist
if you’re wondering, here is the saving code and the error. for some reason when I tried using a dictionary it still gave an error saying i couldnt use dictionaries

save the x and z values ina. dictionary. roblox cant save user data values (includes parts)
Try creating a large dictionary which contains the rest of the data you’re trying to save as well. So it could be like:
{["Data"] = ["Stat1"] = 1, ["Stat2"] = 2, ["Grid"] = {["1,1"] = true}} -- etc.
Honestly a datastore module like ProfileService is pretty useful in these kinds of use cases.
