How to let players save OC's with a custom character?

Hello! I have a character creator in my game that lets people make customly designed OC’s, The problem however is that I want them to be able to save their characters and I don’t know how.

I am still fairly new to scripting but am learning, I know it requires data stores but I am unsure how to start this script or properly prepare it.
An important thing to mention is that I am using a custom model I created in blender with custom clothes also created in blender, So lots of the tutorials I have dived through haven’t helped me.

Any help or info would be greatly appreciated, Please and thank you!

4 Likes

I would guess that you already have the custom character info saved to the player instance in game so that if they reset, the correct character loads automatically. If this data is in a table format, then you can save this table straight to a datastore

2 Likes

I do not, As i stated i am unsure how to prepare this. and unfortunately i don’t know what tables are persay, do you think there is a place you can direct me to help me learn how to use them?

1 Like

If the player is able to truly customise their own character and not just use pre-made characters, then you would want to serialize the character and save it as a table (a table is essentially another name for an array if you’ve programmed in other languages before) in a datastore, just like how @BadDad2004 has stated. Serialization can be quite a difficult concept to grasp if you haven’t used it before. I would recommend that you learn how data saving works with tables, and then have a look at this post regarding serialization

3 Likes

I think we need to take a step back first. Do you have any persistent data storage, ie leaderstats or any other info that is saved when the player leaves and loaded when they rejoin?

1 Like

No, i do have a Ban datastore but i’m not sure if it is exactly what you are talking about.

1 Like

I’d recommend creating a server script to add a Folder to the player and then create a series of Values or Attributes for each “Shirt” as Integer (Int), “ShirtColour” as Color3, etc.

When the player creates the custom character, then update the values created above. For shirts etc, you can save just the asset id itself rather than the full URI to the asset.

Once that is working, then you can think about saving the data. You use a standard Datastore to save and load the data. For that, you will need to serialize the data as explained by @D4_rrk.

An alternative (which I use) is ProfileService, which is a common data saving module, with additional safety features to combat data loss.

3 Likes

you should use my module Easy Datastore. It is designed for new users to utilize datastore without managing the complexities of learning complex datastore modules or learning the edge cases of datstores.

However, if you don’t know anything about game development (even for utilizing a beginner-friendly module yet equally as powerful module to the complex competition such as mine) it may be a bit tricky. Let me know if you’re interested in my module though and I can help guide you through the steps.

2 Likes

Because Datastores don’t let you save instances, you will need to serialize the character, as already stated above. @D4_rrk’s link is a great walk through of the concept.

I am unsure how this “custom character” system actually works, however, if all we are trying to do is save custom-made instances then this shouldn’t be too complicated.

First step is to create a datastore. There are probably a thousand tutorials out there for it, but here are few to get you started:

And then there’s always ProfileService or DataStore V2

The second step, once the datastore is created, is to work on serialization. This can be complex if you don’t really know what you are trying to do. This mostly depends on how your system works. If you could give us more insight on how the system places the skin on the player this would make the process a lot easier.

2 Likes

Hey i noticed you mentioned profile service and datastore2 but I would like to remind you of the new Easy DatastoreV2 which provides the same functionality as these amazing datastore modules but designed to remove the learning curve drastically!

I hope you consider adding Easy Datastore V2 to your arsenal of datastore modules!

1 Like

I was considering adding it to the list, however, at it’s current level of popularity and testing state I wouldn’t say it is as battle-tested as ProfileService and DataStore V2. I am still testing it out in my own testing file. It also doesn’t have proper documentation, leaving certain functions to be confusing.

I was playing around with saving instances with Easy Datastore and noticed that it doesn’t error or warn that it couldn’t save the instance. It just doesn’t save it. I thought this was odd, as when you call UpdateAsync() or SetAsync() with DataStoreService it will always error if you give it an instance. I am still trying to find out why it doesn’t error.

In the future, after several security and comparative tests have been done, it would make a lot more sense to include it in my recommendations. However, right now I wouldn’t consider it “production-ready”, as there are still many bugs that need to be worked out.

Okay I understand. The reason it likely doesnt error is because it doesnt immediately save when you use the module.set() function. Instead it uses autosaving or saves when you leave the game (only if there is data unsaved.) then when it uses the save function it pcalls the error for retry attempts.

1 Like

Got it. I hope that message didn’t sound too harsh, as it wasn’t intended to be harsh. It was supposed to be informative.

In the future I would recommend warning the error message of the pcall, however, I haven’t checked if you do or not.

As many people have said, you may have to serialize the character. However, there is probably an easier option. Since you say you have a “character creator” with objects from blender that you made, I’m assuming you have some sort of accessory selection menu. If this is the case, you could just log down the objects your player is wearing and save the data of that. Also, if you could, sending the character creator scripts would help a bit to determine how you would go about this approach.

2 Likes

So, basically, save the name of the accessory in the Datastore and then load those names and apply the accessories upon joining back?

Yea pretty much. Each accessory could also have its own unique ID in case they have similar names. Also this is also much easier (and probably better lol) to code for a beginner compared to actually serializing everything.

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.