Hello!
I am making this post since my last one went dead without me getting an answer. I’m trying to save and load all the items in a game folder but I’m not doing it right and don’t know how to fic it.
Here’s what I’m trying to save:
Here’s what my code currently looks like, and yes it’s bad but I don’t know datastores well yet.
PlayerAdded and PlayerRemoving is not really necessary in the datastore, BUT it helps getting the player and checking whenever someone is leaving.
Heres how datastore works from my experience
:GetDataStore(stringhere)
This is like a key accessing the storage, you can have multiple storage “box” in one game. To access the “box” just put in a string. For example, a “box” for swords, just input :GetDataStore("Swords"). It can be whatever key you like. It creates a new “box” if it doesn’t exists.
:GetAsync(string/number) basically gets a data from the “box” you just called. The string/number can be whatever
If you want a single player’s data, use the player’s UserId, it will return nil if the player doesn’t have a data(new player)
If you want a SERVER data, aka global data, you can just input your custom string ex: :GetAsync("SwordName")
:SetAsync(string/number, table) Basically just saves the data, it’s like GetAsync, but it’s the saving function.