I’ve been working on this game for a week now and the only problem is I can’t find out how to make a tool saving system so I came here so you guys can help me!
try using this, it can save inventory, you only need a folder for the weapons so the script can grab and duplicate them.:
local dataservice = game:GetService("DataStoreService")
local inventorydata = dataservice:GetDataStore("Inventory")
local itemsfolder = game.ServerStorage.ItemsFolder --replace it to the location of your item folder
game.Players.PlayerAdded:Connect(function(player)
local inventory = inventorydata:GetAsync(player.UserId) or {}
for i, si in pairs(inventory) do
if itemsfolder:FindFirstChild(si) then
itemsfolder[si]:Clone().Parent = player.Inventory--Change this to the folder you want to copy the items back into.
end
end
end)
game.Players.PlayerRemoving:Connect(function(player)
local inventory = {}
for i, si in pairs(player.Inventory:GetChildren()) do-- Change this to the folder you want to save the children of.
table.insert(si.Name)
end
local success, errormsg = pcall(function()
inventorydata:SetAsync(player.UserId, inventory)
end)
if errormsg then warn(errormsg)
end)
do I put the items in item folder
yes, you put the items inside of the folder so the script can function properly.
so I put all the items in the item folder also for the the ones that say change this to the name of your folder
no and yes. The 1st change is the folder of the items and the 2nd and 3rd change is the folder inside of the player to save.
so I don’t put anything in the 2nd and 3rd one
if the folder inside of the player is named “Inventory” then yes
so I put that folder inside of player
yes, but it was the same request basically lol.
he’s just telling more people that didn’t see it
also do I put the inventory folder in players
yes it should be a folder that you put into players. Just to clarify the inventory and item folders should be completely different folders
yep I know also thanks so if I just copy the name of each of those stuff I won’t have to change anything
yes, you can do that if you want.
it didn’t work could I use replicated tho with server storage u can’t buy stuff
well then replace the 1st line with local itemsfolder = game.ReplicatedStorage.ItemsFolder
You mean the third line? Or the firsy
I was talking about the 3rd line.