How would you save the property of a model in game?

Before you say it (cuz I know that SOMEONE is gonna say it), no this doesn’t have anything to do with leaderboards or anything. Anyways, what I want to do is save the properties of a model in game. For example, if you turn the material of a block from plastic to a brick and the rejoin the game, it’s still a brick. If a BoolValue is changed to be false and you rejoin, the boolvalue is still false until it’s changed again. Surprisingly, no body has thought of this topic (and if they did, they’re talking about some bloxburg-like build mode, unless that’s the solution to my problem). An example of what I could use this for is for a one-time use coin. When you collect the coin, a boolvalue becomes false, and while it’s false, the coin is un-collectable.

I haven’t tried any method of doing this

With DataStores, the same way you save the state of anything else in an experience. World data is still data and if you want it persistent then you need a place to store it, thus DataStores.

1 Like

wait a minute, so if I use the same data saving technique that’s commonly used for leaderstats but replace the leaderstats with a part/model, it’ll work just as I expect it to?

DataStores cannot save Instances so you have to serialise it but yes. DataStores are designed for any kind of persistent data, not just player data. Player data is just the most common use case for them but that doesn’t mean they’re the only use case for them.

That being said, those threads you were reading about saving Bloxburg-like building mode structures are also applicable to your circumstance because they involve saving some kind of map state to be loaded later. They could’ve been a basis for helping you resolve your own question which is virtually the same except without the player’s input. It’s still map saving.

1 Like

that is actually something I didn’t know. Before I go use this newfound knowledge, how would I serialize it?

Serialisation is the process of converting a data structure into a format that can be reconstructed later, so for Roblox purposes that’d mean converting something you can’t save into a format that you can.

DataStores will accept numbers, strings, booleans and tables and coerce them into a string format (similar to or JSON itself) but not nils, functions, threads or userdata. Therefore, you need to have a means of translating your parts into these acceptable types so you can save them.

Normally.

It strongly depends on what you want to do though. In your example case which is making a one-time use coin you don’t need to serialise the part, you just need to save the state of the coin. So in your data set you would be saving something that you can remember (e.g. CollectedCoins = {“coin1_townhall_marker”}) and then when you load that data you have all the coins’ states to work with. You go through those states and accordingly adjust each coin to a (non-)collectible state.

Read more: Data Stores

2 Likes