Hello,
I’m trying to store my skins with a datastore; The skins are in a folder, but I’m not sure how I can save everything inside the folder and then load all the items in the folder back.
Here is my current script; I’m not sure if I’m saving them correctly and how can I load them into the skins folder?
Players.PlayerAdded:Connect(function(Player)
local Leaderstats = Instance.new('Folder',Player)
Leaderstats.Name = 'Leaderstats'
local Skins = Instance.new('Folder',Player)
Skins.Name = 'Skins'
local EquippedSkin = Instance.new('StringValue',Leaderstats)
EquippedSkin.Name = 'EquippedSkin'
EquippedSkin.Value = DefaultSkin.Value
local TeddyBucks = Instance.new('IntValue')
TeddyBucks.Parent = Leaderstats
TeddyBucks.Name = 'TeddyBucks'
TeddyBucks.Value = DefaultValue
local Data = TeddyBucksStore:GetAsync(Player.UserId)
local Data2 = SkinsStore:GetAsync(Player.UserId)
if Data then
TeddyBucks.Value = Data.Stats.TeddyBucks
end
if Data2 then
end
end)
Players.PlayerRemoving:Connect(function(Player)
local SaveData = {Stats = {}}
local SaveData2 = {Stats2 = {}}
SaveData.Stats.TeddyBucks = Player.Leaderstats.TeddyBucks.Value
TeddyBucksStore:SetAsync(Player.UserId,SaveData)
for _, Skin in pairs(Players.Skins:GetChildren()) do
SaveData2.Stats.Skins = Skin
SkinsStore:SetAsync(Player.UserId,SaveData2)
end
end)
How can I configure it with my current script? This also saves my coins too!