are there any errors? i just tested the script and it doesnt lose the tool when you’re holding it.
also did you delete the script you originally posted? the one on the first post
I have 2 scripts in serverscriptservice. One is called SaveTools and the other is called SaveTools2.
SaveTools:
for _,tool in pairs(game:GetService('StarterPack'):GetChildren()) do
if not tool:IsA('Tool') then continue end
if not tool:GetAttribute('UniqueID') then
tool:SetAttribute('UniqueID', game:GetService('HttpService'):GenerateGUID(false))
end
end
game:GetService('Players').PlayerAdded:Connect(function(plr)
plr.DescendantAdded:Connect(function(newTool)
if newTool:IsA('Tool') and newTool.Parent == plr.Backpack then
if newTool:GetAttribute("DontSaveOnDeath") then
return
end
if not newTool:GetAttribute('UniqueID') then
newTool:SetAttribute('UniqueID', game:GetService('HttpService'):GenerateGUID(false))
end
for _,existingTool in pairs(game:GetService('StarterPack'):GetChildren()) do
if existingTool:IsA('Tool') then
if existingTool:GetAttribute('UniqueID') == newTool:GetAttribute('UniqueID') then
return
end
end
end
local newClone = nil
for _,existingTool in pairs(plr.StarterGear:GetChildren()) do
if existingTool:IsA('Tool') then
if existingTool:GetAttribute('UniqueID') == newTool:GetAttribute('UniqueID') then
newClone = existingTool
break
end
end
end
if not newClone then
newClone = newTool:Clone()
newClone.Parent = plr.StarterGear
end
newTool.AncestryChanged:Connect(function()
if not plr:FindFirstChild('Backpack') then return end
if newTool.Parent ~= plr.Backpack and newTool.Parent ~= plr.Character then
local hum = plr.Character:FindFirstChildOfClass('Humanoid')
if hum then
if hum.Health > 0 then
newClone:Destroy()
end
end
end
end)
end
end)
end)
SaveTools2:
local toolfolder = game:GetService("ServerStorage"):FindFirstChild("SaveTools")
local dss = game:GetService("DataStoreService")
local saveddata = dss:GetDataStore("SaveData")
game.Players.PlayerAdded:Connect(function(player)
local tooldata = saveddata:GetAsync(player.UserId)
local backpack = player:WaitForChild("Backpack")
local startergear = player:WaitForChild("StarterGear")
if tooldata ~= nil then
for i, v in pairs(tooldata) do
local RSTool = toolfolder:FindFirstChild(v)
if RSTool then
toolfolder[v]:Clone().Parent = backpack
end
end
end
end)
game.Players.PlayerRemoving:Connect(function(player)
local tooltable = {}
for i, v in pairs(player.StarterGear:GetChildren()) do
-- preferable check if v is a tool
table.insert(tooltable, v.Name)
end
if tooltable ~= nil then
saveddata:SetAsync(player.UserId,tooltable)
end
end)
These are the only two save tools scripts. The original was deleted a while ago. The same thing happens. Jump off the map, the tool saves. Jump off the map while holding the tool, it gets deleted.
okay i just tested it and yes it doesnt save if you jump in the void, probably because the void is getting rid of your character before setting your humanoids health to 0, you can maybe fix this if you unequip the tools when the character reachs a certain height (-400), or i’d just not be concerned if theres not alot of jumping into the void in your game