Hello devs! I’m working on a RPG game and would like to make a Datastore for the inventory to save.
Since I don’t know the datastore very well even in my 2 years of scripting I tried watching videos or searching in the Forum but I can’t find any working script.
If anyone knows a working inventory model or script that I could use please let me know I’ll just have to edit it.
Thank you! If you have any questions please let me know.
What i do to save inventory and amount of items is just using a simple StringValue. After that, to count how much of each items, just count occurence (Which could be easly found on google)
Well, your inventory system data will probably resemble some sort of 2d array.
You can directly save this array to the datastore depending on how you’re storing the data.
I would suggest starting with the actual inventory system, and then worrying about how to save it. Its hard to save a data structure when you don’t know how its going to be formatted.
local function OccurrenceCount(Pattern, String)
return select(2, Pattern:gsub(String, ""))
end
you just need to put the Pattern, the string you want to know the amount and that’s all.
For example if you have “BananaBananaAppleIron” and you want to know Banana, you just have to do:
local amount = OccurrenceCount("BananaBananaAppleIron", "Banana)
and it should return 2 since the word Banana is there twice
Im not sure why it would be good to store your data like that. Arrays are much neater and roblox provides built in functions for us. Look into 2d arrays, the link i provided above has examples.
This is illogical. Using an array is not having “thousand datas”. It just a more organized way to store multiple values. I understand you’re trying to help, but please don’t speak on threads if you don’t know what you’re talking about. Giving bad advice not only hinders his ability to accomplish his goal, but now everyone else who looks back at this in the future has to read through inaccurate advice.