Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How can i write save/load scripts with multiple instances?

Asked by 9 years ago

Alright, so i made a Save Data script, where you save multiple instances, (precisely, parts on a player, like a morph)

However, how do you save it?? Do i save it with the inpairs or no? I'm kinda confused.

Also, I had trouble loading it, because i wrote a save/load script, and it's supposed to check if the player has saved onto the game or not. And if the player didn't save, it would bring them to a create-a-character menu.

If there's any corrections/fixes, please let me know! :)

1 answer

Log in to vote
0
Answered by 9 years ago

If you're using DataStores, you need to encode the instances as a table, number, or string somehow. The easiest way to do this is to store a string representing the name of the morph.

If you're allowing customized morphing (where the player can adjust colours, positions, sizes, or other storing the name of the morph won't be sufficient - you have to store the player's adjustments too. Personally, I'd convert the model to a string, as I have the most control by doing that, but this process is not easy to explain. The easier way is to save each part in a table using the method outlined in this question

0
However, if you do convert the model to a string, it is seperated in a ton of parts x.x Annd, some of the parts have meshes, what do you do with those? CrammelApple 50 — 9y
0
You have to come up with a format that your script uses to represent a part. An inefficient one might say "Let 'x' be the start of a new part and let me just store the position and size and 'y' be the start of a new mesh". Then you might save "x12.3,5.6,9.1,4,1,4y58982". chess123mate 5873 — 9y
0
Alright, but when comes the time you have to put the mesh ID? For example, you write out the part, do you have to make an instance.new and add a meshID to it? (Sorry if i'm asking so many questions, i'm not exactly very good) CrammelApple 50 — 9y
0
The "58982" was my example of the mesh ID. The whole string in my example would mean "a part at (12.3,5.6,9.1) sized at (4,1,4) with MeshID 58982". You'd read the string segment by segment, assigning properties/children as needed. chess123mate 5873 — 9y
0
However, if you're writing things for colors, and you can't save ColorValues, how do you convert those to strings, and save them? I've already made a table full of the names of the possible colors, but how do you convert object.BrickColor into something that related to "Bright Red", you do object.BrickColor ("ColorTable") ? CrammelApple 50 — 9y
Ad

Answer this question