Save Entire Folder of Values

how do I save the entire contents of a folder (there are String Values and Int Values) to data store and then when the player joins again will the Value appear again in the folder? but the contents/child in the folder can be increased or decreased. That’s why I’m asking how to save the entire contents of a folder to the datastore?

Because I want to make like “Notepad Save” system, like regular Windows notepad, where player can save their notes, not only one note.

Simple. You use dictionaries. Dictionaries are tables where the indexes can be anything but most of the time they’re strings.

Assuming you know how to use DataStoreService, you can save the data like so with folders:

local function SavePlayer(player)
	local TheirFolder = ??? --// Path to their folder
	local DictionaryToBeSaved = {} --// Dictionary we are gonna save for the player
	for _, Value in ipairs(TheirFolder:GetChildren())
		--// Where value is the IntValue, StringValue, etc.
		DictionaryToBeSaved[Value.Name] = Value.Value --[[ This structure will make something like this:
			Coins = 500,
			Level = 10,
			Rank = "Admin",
	--// Save the Dictionary
	DataStore:SetAsync(Key, DictionaryToSave)

Then if you wanna load it:

local function LoadPlayer(player)
	local PlayerData = DataStore:GetAsync(Key) or {}

	local TheirFolder = ???

	local CoinsValue ="IntValue")
	CoinsValue.Value = PlayerData.Coins or 0
	CoinsValue.Name = "Coins"
	CoinsValue.Parent = TheirFolder

	--// Etc for all the other values
1 Like

For the loading part, it would definitely be better to have a for loop, as it would be shorter and cleaner.

1 Like

True I was thinking about doing that, but you’d also have to know whether the value is an integer or a float number.

Well, you can have a function where you check if there’s any decimals.

Welp, you can also save the data like this so you know for sure:

	Coins = {
		Value = 500,
		Type = "Int"
1 Like