I have a folder located within the player where it is used to store hats the player gets. I made this script and put it into workspace (also tried ServerScriptStorage) both didn't work. The script is a regular script...
local DataStore = game:GetService("DataStoreService")
local ds = DataStore:GetDataStore("HatSave")
game.Players.PlayerAdded:Connect(function(player)
local hats = player:WaitForChild("Hats"):GetChildren()
for _, child in pairs(hats) do
child.Parent = ds:GetAsync(player.UserId)
ds:SetAsync(player.UserId, child.Parent)
end
end)
game.Players.PlayerRemoving:Connect(function(player)
local hats = player.Hats:GetChildren()
for _, child in pairs(hats) do
ds:SetAsync(player.UserId, child.Parent)
end
end)
I don't know how efficient this method is, but feedback is always good

1 comment
You can't save Instances, you can only save Strings, Numbers, and Booleans.