How should I go about compressing this data for DataStores?

I have a spray painting that has a save feature in the game, but it uses parts to paint, meaning the part count can go up to 100k+ sometimes on larger art pieces. Currently when saving, I group the parts together by color and store their position, rotation, and size in the dictionary they are saved in.

Unfortunately, Roblox limits the DataStores to 4 MB, which is limited to ~60k parts (paint) in my game with my current saving technique, which causes erroring and data loss on larger saves. How could I further decrease the size of the dictionary I generate for larger saves?

One method is to JSONEncode the data, other than that you can check if the #HttpService:JSONEncode(data) is above 4MB, if that’s true, save the painting inside multiple datastores or limit the player from drawing more.

It might be best to do some rounding on the numbers you’re saving (or rounding on the paint colors before it is applied to parts). So instead of Color3 values such as “Color3.new(0.1234, 0.1234, 0.1234)” you’d instead opt to save/paint the color as “Color3.new(0.12, 0.12, 0.12)”. How much rounding (which will determine how much color precision is lost) you want to perform is entirely up to you.

For one, provide some snippets of your code so we can analyze how your going about saving data.

  • Convert data such as Position and / or CFrame, Color, Size etc - to strings.

  • Limit the amount of instances you need to datastore all together, for example if someone has two “paint drops” overlapping (like both drops have the exact CFrame) destroy the other and only save one of said parts data, this can also reduce the amount of parts in game which can reduce lag.

  • You could also try exporting excess or a certain data types (example only color data) to an external database or website.

  • And lastly you could save the data in a sort of a “bundle”.

Hope this helps :slight_smile: