Making a Datastore save a tycoon

Hello. I am trying to make a datastore that saves a players tycoon. I have 0 idea of where to start, and dont even know how its going to work. I have a datastore for my leaderstats which was pretty easy, now I just need to implement it for the actual tycoon its self. If you could just tell me how to even go about it I would be very much in your debt, thank you fellow developers

1 Like

I highly recommend this complete series:

2 Likes

I have never scripted any tycoons but there’s a module I know that is able to convert an instance to a table or convert that table to an instance while keeping all the same properties the instance had before. Here it is: Converter Module: Instance ↔ Table | Save Instances to DataStores and More!

I use it for my building game where players have plots and they could build stuff from blocks on them with different block shapes, colours and materials. This module has saved me so much time and brainstorms, I am very thankful for it even being a thing.

The best thing is that it works lightning fast and doesn’t even lag.

Here are the features:

  • Supports the DataStore/DataStore2 format.
  • Supports object variables†.
  • Supports Workspace and Lighting properties.
  • Can be used without HTTP Service.
  • Many customizable settings available.
  • Complete backwards compatibility.
  • Full attribute support.
  • Supports ALL data types (CFrame, String, Vector3, UDim2, Ray, Faces, etc.)
  • Compatible with the ModuleScripts created from the Instance to ModuleScript Converter plugin.
1 Like

Holy, this is a god send. This actually might be the thing I use, thank you so much! Im going to go test this out.

1 Like

Indeed it is, modules are really useful things and you should be thankful the community of Roblox developers are that creative and always exceed the limits trying new things out.

If you would like another solution besides the resource provided by @BandQueenForever, you would need to understand the concept of serializing data. You can’t actually save instances like the parts of a tycoon but you can learn to serialize them. To serialize data you basically just need to save references to the instance that you are trying to save. Let’s say we have part of a wall in your tycoon and the player now has bought it. You can save that wall by saving its data. Instead of saving the entire instance you can save just the position or the name and then when the player loads into the game again, you can create a new part with the same position, size, name, and other important variables you would like to save. Serialization can come in handy when you’re trying to save data that you wouldn’t be able to save normally.

I would like to know what data you’re trying to save so that I could provide a better example and better advice! If you already know about serialization then great! If you don’t I found a good resource that helps you understand it.

I think the module I suggested does the same thing but when I was searching for a way to save plots and load them, I couldn’t find anything simpler than the module. Of course, I found the serialization tutorial you linked but it’s just way too confusing (for me) and time wasting.

2 Likes

I just wanted to provide it since I think knowing how to serialize data can come in handy, but the module provided does seem good enough. Serialization can also be helpful when it comes to creating algorithms to compress and save space. If you can do that with the module you provided that would be fantastic!

1 Like

Wow, that blew my mind. Pretty complex, but I think it might be worth using that over a module that might have bugs and other unwanted stuff

2 Likes

I have scripted a tycoon system before. I haven’t gotten to any of the saving parts, but the way I designed it was for each tycoon object, I have a function I can run to “purchase” a part. I also have a table to identify which parts have been bought. I can save the table, and then purchase every part when the player obtains ownership of the tycoon.

2 Likes

Thanks for sharing the module @BandQueenForever :smiley: but serialization might be the wrong approach for OP.

Here’s a snippet from that module post:

The module is more-so intended for plot saving and sandbox builds.

In this case it looks like you only need something for a tycoon, which should be pretty straight forward. For a tycoon, you’ll want to do something like @SubtotalAnt8185 said, save a unique name or id in a table for all the player’s purchases, save that table to a DataStore, and give them their purchased structures/upgrades (using the unique id) when they claim a tycoon in their next session(s).

The playlist @Maks66606 linked seems to have a video for all the tycoon fundamentals including DataStores. If you’re just starting out, I’d suggest giving those a watch to get a good understanding of how tycoon systems work.

1 Like

I agree, this would be much simpler and would take much less space than serialization. I suppose if you’re making your Tycoon very modular and infinitely sized then serialization would be a better option but if the Tycoon is the same every time then it would be better to do something that wouldn’t be as difficult or take as much space as serialization.

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