Built in .rbxmx XML Asset Serializer & deserializer

Introduction

As a roblox developer, it is currently too hard for us to allow for players in games to create custom models, then send them to different levels / places in the player’s teleport data. An API that allows for the serialization of models, and other assets in the game would solve the issue

What is Serialization?

Serialization in this case is to turn game assets (models, parts, scripts, etc.) into encoded text that can then be decoded and turned back into a game asset by a deserializer. This is useful because we cannot send objects through the teleport service.

My Application

My project right now consists of allowing a player to customize their car, then when they challenge another player to a private duo race, the freeroam server will reserve them a server and send them and their vehicle (through teleportData) to a new level (the 2 player max. server) that manages the race. Once a player wins or time runs out, the two players will be brought back to the freeroam server and the winner will get a prize.

To get these custom-built vehicles with specific upgrades and information stored in a module within the car to the new server, I would need to have a way to serialize the car’s visual and performance data so it can move through the teleport service. My current (planned) method consists of using Crazyman32’s serializer plugin (which I converted to a module I can call on) to create a moduleScript that spawns the car. The source of this script is returned by the module as text, then the text is sent through the teleport service. On the new level the player reaches after the teleport, the teleportData (source to the loader module) is run using the loadstring() method. That will return the car object, which then can be spawned. This would usually work, but unfortunately there are problems with this:

  • The serializer has no way to deal with Unions
  • MeshParts cannot have their MeshID written to
  • Scripts cannot be serialized and moved.

Other Applications

  • Building game where you build a tank in one server then fight in another
  • Tycoon game where you build placable objects for your tycoon in one server then place them in another
  • Saving object data for players to the datastore

Conclusion

I really think a built-in asset serializer and loader would be a nice addition for roblox devs and would make the place - to - place integration more seamless and custom. Thanks!
-big

13 Likes

I mean, technically this is already possible using DataStores. You can just store the unions on the server somewhere and then use a clever trick to load them in (like maybe a placeholder part at its CFrame). Obviously that isn’t fun, but it works.

I do think something like this would be insanely useful. It’d be particularly helpful in saving player bases in one of my unfinished games. I don’t plan on including the feature because of the headache associated with it.

What headache would that be? it’s really just creating a lua API to load & save XML data. It’s already a feature in studio (for saving rbxmx files to the hard drive) but could be useful implemented in game.

1 Like

I didn’t realize what category I was in and this got me p hyped. 0 to 60 to 0.

I too would have a use case for such a feature, that being to perform syncing between studio & filesystem for arbitrary models (including, as mentioned in OP, unions & meshes). I like to use version control, and anyone who’s used version control knows, it’s nice to have things such as diffs/logs for single files rather than having one binary *.rbxl file which you can move forward/backward in history with, but nothing more.

3 Likes

I don’t read or write XML so the way I was thinking of serializing everything would have been… interesting.

If such a feature is already partly available though that would make this even more viable. I’d be more than happy to use something like this to convert my stuff to XML and then back again.

But like I said, there’s many methods to serialize objects so I don’t know if it’s worth it to support this in the engine.

1 Like

Yes but how would you move assets through to different games / servers? Like my example, it would be impossible to generate a car from the serialization tools we have available at the moment. All the car settings are stored in a module and since we can’t set script sources via script, you’d need to use loadstring() or something. Not to mention that we still can’t serialize models, and I’m not sure what you mean by saving a union to the server then reloading it - which server? The game server is different every time and the web server would fill up my inventory - not only that but it’s hacky.

You could use data stores to transfer data across servers in the same universe.

You could then literally store the unions you need somewhere like ServerStorage.

When you need to save a union, save a placeholder part instead.

When you load the model, you can then grab the union from ServerStorage and put it where the placeholder part is.

I don’t see why you would need this across different games? Even if this were such a feature I think that would be niche.

And I’m not against the feature request, I’m just saying you can already accomplish what you want if you get clever.

oh alright that clears it up a little bit - but that wouldn’t allow for saving of unions that are inserted with the insert service, or handle out of date servers anyways. Not that you really should have to worry about out of date servers too much since you could always shut them down, but yea I understand what you mean now. I guess that would be possible but quite difficult especially if there are a lot of unions.

1 Like