Outputting binary data

So I have this voxel building game and I want to make it so you can save world data. I have decided to save it as a binary string because it would take up less bytes than saving it in a normal string. I also want it to be saved as a file on the user’s computer. I would do this by asking the user to copy+paste the outputted binary string from a TextBox.

The problem is that when I do this, even though it says that there are 13414 bytes in the string, I can only select 7.

I also heard that it’s a problem saving it to datastores, too, though I don’t want to save it to datastores because a very small world would take up 13kb.

1 Like

There are ways to bypass the “limit” of roblox datastores by using more than one key, and storing all user keys in a master key, which would work something like this:
Player Id = 1576
“Master” datastore key would be 1576, and that would contain a table with different keys to load like this: {1576.1, 1576.2, 1576.3} (the period is there to prevent someone from having their “Master” key overwritten by someone else’s other key, as uids never have periods in them) and so on. Keys have a 50 character limit, so this would work fine as long as you aren’t using over 39 keys (roblox currently has 1 billion users, 1 billion is 10 characters in length). Data Store Errors and Limits

Using your user saved system can bring up a few issues, such as users needing to copy and remember where the save file is located, and this removes any hope of being able to play anywhere, such as mobile or console. This also allows for users to input invalid things, and allows for them to input something that would give them whatever they wanted. If someone cracks the code for decoding/encoding they can add whatever blocks they want to their saved data. With datastores, the server controls the data, and you can store more than just binary, as that could possibly use more space than just plain text. If you want to compress text, I highly recommend Text compression to save space in datastores.

what’s wrong with that? they could do that in-game anyway

It prevents exploits and it promotes good code with a server authoritative model. I assume with this you’ll eventually want some survival type gamemode, and with this type of data loading system anyone, even without exploits, can have whatever they want.

If I still used binary, how would I save it into a datastore? I want to be able to store “01100001” as “a” if you read it as a text file.

You’d use whatever system you’re currently using to encode and decode the binary, and use :SetAsync(key, tostring(data)) to save it. Here is the documentation for datastores: https://developer.roblox.com/en-us/articles/Data-store

Why not just only save blocks that have been edited by players, first create the map and store each blocks position as a key, and the block data as a value, but keep track of blocks players have edited. This way you only have to save that data, and data used to generate the terrain.
I wrote this on mobile so it might seem a little vague and confusing. If you would like to me to explain more in depth I can (: