So I am currently creating three tabs of inventory, which are swords, potions, and magic. They are all made in Backpack. My Backpack GUI does register them each and they are also cloned in a specific folder when I buy them from the shop. So when I die, it'll save the tools and there place inside. But it duplicates the folder (2x) one with the tools and the other which is empty, while the tools duplicate (2x) inside of the folder that has tools. And also it doesn't save the tools when I leave and then rejoin the game too.
local InStudio = game:GetService("RunService"):IsStudio() if not InStudio then sword = game:GetService("DataStoreService"):GetDataStore("Swords") potion = game:GetService("DataStoreService"):GetDataStore("Potions") magic = game:GetService("DataStoreService"):GetDataStore("Magic") end function savedata(dataname, playerid, value) if InStudio then return end dataname:SetAsync(playerid, value) end game.Players.PlayerAdded:connect(function(player) player.CharacterAdded:connect(function(char) local data1 = nil local data2 = nil local data3 = nil data1 = sword:GetAsync(player.UserId) data2 = potion:GetAsync(player.UserId) data3 = magic:GetAsync(player.UserId) local sword = Instance.new("Folder") sword.Name = "Swords" sword.Parent = player:WaitForChild("Backpack") local potion = Instance.new("Folder") potion.Name = "Potions" potion.Parent = player:WaitForChild("Backpack") local magic = Instance.new("Folder") magic.Name = "Magic" magic.Parent = player:WaitForChild("Backpack") local sword = Instance.new("Folder") sword.Name = "Swords" sword.Parent = player:WaitForChild("StarterGear") local potion = Instance.new("Folder") potion.Name = "Potions" potion.Parent = player:WaitForChild("StarterGear") local magic = Instance.new("Folder") magic.Name = "Magic" magic.Parent = player:WaitForChild("StarterGear") char.Humanoid.Died:connect(function() char.Humanoid:UnequipTools() local old = player.StarterGear:GetChildren() for i = 1, #old do old[i]:Destroy() end local new = player.Backpack:GetChildren() for i = 1, #new do new[i].Parent = player.StarterGear end end) end) end) game.Players.PlayerRemoving:connect(function(player) savedata(sword, player.userId, player.Backpack:WaitForChild("Swords")) savedata(potion, player.userId, player.Backpack:WaitForChild("Potions")) savedata(magic, player.userId, player.Backpack:WaitForChild("Magic")) end)