I have a simple question, how can I make an inventory system with DataStores?
I’ve attempted to do this a lot of times but I failed a lot and I’ve resorted to the DevForum. I know how to make DataStores, but I can’t find a way to save a Folder to a player, the DataStore only works when I save IntValues and StringValues to it, so it would be greatly appreciated if anyone could show me how to approach this issue. Thanks in advance.
You’d want to save those ‘folders’ as tables or dictionaries.
-- save this to datastore
local weapons = {'gun', 'knife', 'sniper'}
Then, you can repopulate an actual folder instance using that data.
-- Hierarchy
Folders
Player
Weapons
-- Repopulate
local playerFolder = Folders[player]
local folderWeapons = playerFolder.Weapons
local playerWeapons = {} -- fetch datastore here
for _, weapon in pairs(playerWeapons) do
-- assuming you want to add an actual weapon...
-- add each weapon to folder
-- use 'weapon' to find the actual weapon in your game
end