I want to save an arbitrary model that a player built in my game and load it latter when the player comes back.
Is this currently possible?
I think right now the state of the art is I would need to write my own model serializer, then save to a DataStore, breaking up my binary data into 64kb pages (limit on the size of a value in a DataScore key value pair?) Either that or build my own backend and do HTTP post to it?
Has anyone written a nice abstraction layer over the DataStore backend to make it look more like a file system for developers who want a file system?
Most if not all games with user-generated content serialize instances and save it to a DataStore. If the size exceeds the maximum value size then the data should be broken up and saved into multiple keys. This should only be used if the assets being loaded are uniquely created per player.
Serializing binary data wasnât really worth until recently with the bit32 library. Generally even âbinaryâ â base64 is significantly more expensive than just packing it into JSON.
You can serialize your instances directly (i.e. try all the properties), but Iâd recommend against doing this, and instead serialize into a middleish abstract layer where you control the properties that are serialized.
Building your own backend isnât horrible, but then youâre paying for servers, and you have to setup scaling and maintenance.
All things considered, if you have a game that has no profit and youâre paying for servers, something is seriously wrong. Typically, the only thing Iâll scale out myself is database handling. Even then, the pipeline is purely in Rbx lua and no web server is used.
For this scenario, Anchored, CanCollide, CFrame and BrickColor properties would suffice. You could accomplish this by iteration or recursion. I do agree that storing every property is both wasteful and inefficient.
I believe this is the closest API available for instance serialization, but it only has a very specific use case.
The ideal solution would be to save the instance as a model in the ownerâs inventory, and then load it back later using InsertService.
Your most reliable option at the moment is likely to save every individual instance present in the model just by className to save space, and then when properties of the instance have changed to something other than âdefaultâ, mark those changes. With this method most decently sized models could be saved with a single dataStore
That being said, an api along the lines of âCreateAssetInPlayerInventoryAsyncâ would be a good feature request, considering that robloxâs built in asset saving system can save huge models across games, and synergizes with insertService