How do i datastore children of a folder?

  1. What do you want to achieve? Keep it simple and clear!
    Save a folder with skins owned in the player with the children
  2. What is the issue? Include screenshots / videos if possible!
    I can’t save the children
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I tried seaching for it but i could not find the solution.
    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!
-- local dataStoreCash = game:GetService("DataStoreService"):GetDataStore("MoneyData") -- Maakt de opslag aan voor de leaderstat
local dataStoreDiamonds = game:GetService("DataStoreService"):GetDataStore("DiamondsData")  -- Maakt de opslag aan voor de leaderstat
local dataStoreSkins = game:GetService("DataStoreService"):GetDataStore("SkinsData") -- Maakt de opslag aan voor items die je hebt gekocht (garage)


starterCash = 0
starterDiamonds = 0


game.Players.PlayerAdded:Connect(function(plr)
	
	local GarageSled = game.Workspace:WaitForChild("GarageSled")
	local leaderstats = Instance.new("Folder") -- Maakt een map voor de leaderstats
	leaderstats.Name = "leaderstats" -- maakt de naam voor de leaderstats
	leaderstats.Parent = plr -- staat waar de leaderstats zijn

	local money = Instance.new("IntValue")
	money.Name = "Coins"
	money.Value =  dataStoreCash:GetAsync(plr.UserId) or starterCash
	money.Parent = leaderstats
	
	local Diamonds = Instance.new("IntValue")
	Diamonds.Parent = leaderstats
	Diamonds.Name = "Diamonds"
	Diamonds.Value =  dataStoreDiamonds:GetAsync(plr.UserId) or starterDiamonds
	local OwnedSkins = Instance.new("Folder") 
	OwnedSkins.Name = "OwnedSkins" 
	OwnedSkins.Parent = plr 
OwnedSkins.Children =  dataStoreDiamonds:GetAsync(plr.UserId) -- i wanna load it here
end)

game.Players.PlayerRemoving:Connect(function(plr)

	dataStoreCash:SetAsync(plr.UserId, plr.leaderstats.Coins.Value) 
	dataStoreDiamonds:SetAsync(plr.UserId, plr.leaderstats.Diamonds.Value) -
	dataStoreSkins:SetAsync(plr.UserId, plr.OwnedSkins) -- i wanna save it here

end)

1 Like

It is not possible to save instances to data stores. Try for example saving a table of the folder’s children names (strings).

How do i do that? (i’m a beginner)

You could use a table that contains every single owned skins the player has, instead you get the skins’ name which is a string and use it for reference. When loading the data, you go to whatever parent that has the skins from and refer the table they had, which you have to iterate the table where each element is a string, then use :FindFirstChild(stringName) to get the skins they owned, in which you have to clone the skins first.

2 Likes

How do i do this (im sorry i am very noob)

I just realised that i can just make them boolvalues that every player has and then just make them true if you have that item and save the value

That would be laggy when player has 500 or 1000 or more!