I want to know how to save something and clone it and put it back to the same place again or some other places
for example save player’s hat and when they rejoin clone the hat and put it back into player
This is my current script
local dataservice = game:GetService("DataStoreService")
local inventorydata = dataservice:GetDataStore("QuestSaved")
--local itemsfolder = game.ServerStorage.ItemsFolder --replace it to the location of your item folder
game.Players.PlayerAdded:Connect(function(player)
local questFolder = Instance.new("Folder", player)
questFolder.Name = "QuestsFoler"
local questFolder1 = Instance.new("Folder", questFolder)
questFolder1.Name = "Quests"
local inventory = inventorydata:GetAsync(player.UserId) or {}
for i, si in pairs(inventory) do
local JJD1 = inventory:Clone()
JJD1.Parent = player.QuestsFoler.Quests
--player:WaitForChild("QuestsFoler"):WaitForChild("Quests")
end
end)
game:BindToClose(function()
for i,v in pairs(game.Players:GetPlayers()) do
local inventory = {}
for i, si in pairs(v.QuestsFoler.Quests:GetChildren()) do-- Change this to the folder you want to save the children of.
table.insert(inventory,si)
end
inventorydata:SetAsync(v.UserId, inventory)
end
end)
game.Players.PlayerRemoving:Connect(function(player)
local inventory = {}
for i, si in pairs(player.QuestsFoler.Quests:GetChildren()) do-- Change this to the folder you want to save the children of.
table.insert(inventory,si)
end
local success, errormsg = pcall(function()
inventorydata:SetAsync(player.UserId, inventory)
end)
if errormsg then
warn(errormsg)
end
end)
I’m cloning boolvalue and place it in a folder inside player
Hope you guys can help me