How to save values in a folder using GetChildren()?
Asked by
5 years ago Edited 5 years ago
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:
01 | local DSS = game:GetService( "DataStoreService" ) |
03 | local PlayerCash = DSS:GetDataStore( "Money" ) |
05 | game.Players.PlayerAdded:Connect( function (Player) |
06 | Player.CharacterAdded:Connect( function (Character) |
07 | local Cash = Player.Folder.Money |
08 | Cash.Value = PlayerCash:GetAsync(Player.userId) or 0 |
10 | game.Players.PlayerRemoving:connect( function (Player) |
11 | PlayerCash:SetAsync(Player.userId, Cash.Value) |
15 | PlayerCash:SetAsync(Player.userId, Cash.Value) |
and i currently trying to mix it with this (to hold more values) :
04 | for i,v in pairs (playerFolder:GetChildren()) do |
05 | table.insert(dataToSave, v.Name) |
09 | dataStore:UpdateAsync(key, function (oldValue) |
16 | local loadedData = dataStore:GetAsync(key) |
17 | for i,v in pairs (loadedData) do |
18 | local n = Instance.new( 'Folder' ) |
20 | n.Parent = playerFolder |