Saving/storing tables in a object?

Hello! Apologies if this is a really easy or simple question, but I’m new and have tried to search this on google and the developer forms and haven’t found something that really solves the problem or is what I’m looking for. Sorry if this is really obvious, I might just be thinking about it the wrong way.

I know that you are able to save data to a DataStore, but there is some rate-limiting/cool-downs for doing it on a user (which is very reasonable).

I wish to try and get around this by saving it as an object that can be accessed easier through scripts, and so it can be easily edited with no rate-limiting. Then it would autosave to the DataStore after ~60seconds.

I know that I could use Value objects, but doing this seems like it would take up lots of space, and it would just be very bulky and unorganized.

6 Likes

This question doesn’t make too much sense. Tables are objects as well.

If you are exceeding the rate limit, then that is a faulty implementation. Can you please elaborate on your use-case?

im not experienced with these or anything, but shouldn’t you use modulescripts or something

2 Likes

Sorry, I might be getting confused with some of the names of some things as I’m new to lua and how Roblox has everything laid out. I’m more familiar with things like node.js, so it’s taking awhile for me to get the hang of things. As far as I can see, there is only a LocalizationTable object.

One example would be having some sort of inventory system.
I would like some sort of way to store the data in one chunk that isn’t based off in the DataStore cloud thing. Being able to put custom statistics of an item and the amount possessed of it would be pretty much impossible to do with the Values objects. If I were to have this in the DataStore storage thing, changes would occur fast enough where it would likely be placed in the queue.

1 Like

Yeah, you should use a module script for this. You can store all the data in a dictionary and have the key as the player name and the value as the table. Module scripts can be accessed from any other scripts allowing you to read or manipulate the data easily.

4 Likes

Thank you!

I was thinking of module scripts more as a way to stay organized and DRY, but now I see how it would very convenient for storing the data as well.

1 Like

I read this and it inspired me and helped me make a Table to Object module, so if anyone needs it here it is: Table To Object - Any Object-Based Value and functions!

It’s basically a TableValue (as an object).
Except you would have to do .Value on the values, really simple;
I tried saving data from leaderstats with it, it worked, though I woudn’t recommend it.
Depending on your use case, you might wanna do module, or the way I did it.

(Not compatible with objectvalues currently working on that.)
Obviously not compatible with functions that should be done with Modules.

Actually I guess now it’s compatible with functions guys… Yeah. I did that, there’s improvements coming, like being able to delete a function, but over-all it seems fine. As long as you’re not creating A lot of functions at once.

Happy Christmas!

1 Like