How to save a bunch of values in a folder?

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!

I need to make a saving system for a bunch of clothing (30+), I have a system that makes bool values with the clothing names (Owned or Not Owned) I just need to figure out how to save the values that corresponds to the clothing name. I don’t want to do a datastore per item, I’d like a table and then save said table and when the player joins a function takes the already created values, matches them, and assigns the correct value from the table

  1. What is the issue? Include screenshots / videos if possible!
    I have the slightest idea how to load and save values in a table or anything like that

  2. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

I look but none of them make sense or are related to my issue

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

this image is the code used to create the value and the stuff at the bottom is my guess on how it would filter, How do i save the Bool Value name and the value itself?

Datastores don’t need to be values, they can be tables too. For example:

assert(pcall(function()
  DataStore:SetAsync(playeruseridhere, {Item = "Value", Item2 = "Value"})
end))

Snazzy, but I don’t want to enter

for every item. How would I save the true or false values and the name to load it with?

Is this what you mean?

{
  Name = false,
  OtherName = true
}

I need to save the name and it’s value

Then when loading I find the name inside the already created folder, ensure it’s there, Change it’s values to what it was saved as

So if

that is what this means then yes

Yes that’s what it means.

{
  Name = Owned,
  Name2 = Owned2
}
1 Like

Thank you, How would I collect the data? It would be best if I could put it in a loop. How would I save it? and lastly, How would I load it?

I recommend using a DataStore module for this. They save the data of the player when they leave without the queue warnings.

Try it and learn it. This is what I use.

Well, as @Find4U2Go recommended, saving them in tables is the best. For instance

game.Players.PlayerAdded:Connect(function(plr)
	--this is just a small bit for the loading of data
	local data = ds:GetAsync(plr.UserId)
	
	for i,v in pairs(data) do
		local item = OwnedClothing:FindFirstChild(i)
		
		if item then
			item.Value = v
		end
	end
end)

function save(plr)
	local data = {}
	
	for i,v in pairs(plr.OwnedClothing:GetChildren()) do
		data[v.Name] = v.Value
	end
	
	ds:SetAsync(plr.UserId, data)
end

game.Players.PlayerRemoving:Connect(save)

game:BindToClose(function()
	for i,plr in pairs(game.Players:GetPlayers()) do
		save(plr)
	end
end)

Now, I only provided the saving parts, but I think you can figure the rest out.

3 Likes

Thank you very much! @Kaid3n22 and @Find4U2Go