So I have a fully working without any problems a tool save the problem is tho i have a numbervalues in each tool that i need to save since its the one holding how many tools of that tool u have
The issue is basicly just that i am not sure on how i would add this to the datastore i am not asking for a full script or anything like that just what i need to do.
Solution i have tried is to save it to a table and get the tonumber from it it prints and stuff but the problem i had that was that it will just randommize the numbers on each tool even if i get the name
The lua code i have so far
local DataStoreService = game:GetService("DataStoreService")
local toolsDS = DataStoreService:GetDataStore("PlayerBackpackSave")
local toolsFolder = game.ServerStorage.Tools
game.Players.PlayerAdded:Connect(function(Player)
local ToolsSaved = toolsDS:GetAsync(Player.UserId .. "-Tools") or {}
for i, toolSaved in pairs(ToolsSaved) do
if toolsFolder:FindFirstChild(toolSaved) then
local Clone1 = toolsFolder[toolSaved]:Clone()
local Clone2 = toolsFolder[toolSaved]:Clone()
Clone1.Parent = Player.Backpack
Clone2.Parent = Player.StarterGear
end
end
Player.CharacterRemoving:Connect(function(char)
char.Humanoid:UnequipTools()
end)
end)
game.Players.PlayerRemoving:Connect(function(Player)
local ToolsOwned = {}
for i, ToolsInBackpack in pairs(Player.Backpack:GetChildren()) do
table.insert(ToolsOwned, ToolsInBackpack.Name)
end
local Success, Errormsg = pcall(function()
toolsDS:SetAsync(Player.UserId .. "-Tools", ToolsOwned)
end)
if Errormsg then warn(Errormsg) end
end)