Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How to save values in a folder using GetChildren()?

I already find this [https://devforum.roblox.com/t/folder-getchildren-datasave/284730] but i dont know how to use this informations to make a working script. I cant save all my values one by one cause i have 18 values... My save script (for one value) actually look like this:

local DSS = game:GetService("DataStoreService")
 
local PlayerCash = DSS:GetDataStore("Money")
wait(0.04)
game.Players.PlayerAdded:Connect(function(Player)
	Player.CharacterAdded:Connect(function(Character)
    	local Cash = Player.Folder.Money
    	Cash.Value = PlayerCash:GetAsync(Player.userId) or 0
 
		game.Players.PlayerRemoving:connect(function(Player)
			PlayerCash:SetAsync(Player.userId, Cash.Value)
		end)
				while true do
			wait(70)
			PlayerCash:SetAsync(Player.userId, Cash.Value)
			end
	end)
end)

and i currently trying to mix it with this (to hold more values) :

--Saving data
local dataToSave = {}

for i,v in pairs(playerFolder:GetChildren()) do
     table.insert(dataToSave, v.Name)
end

--Save the table to a key
dataStore:UpdateAsync(key, function(oldValue)
    --Do some kind of check if you want
    return dataToSave
end)

--Loading data
local loadedData = --Load data from key
local loadedData = dataStore:GetAsync(key) --Example
for i,v in pairs(loadedData) do
      local n = Instance.new('Folder')
       n.Name = v 
       n.Parent = playerFolder
end

1 comment

0

Sorry for my bad english

1 answer

Just use .:AutoSaver:. by Clirex and replace all the word leaderstats for the name of your folder.

This discussion is preserved as it was. New answers, comments, and votes are closed.