Hello so sometimes and for some players it doesn’t delete the Touchinterest on death for the tools!
code:
local character = script.Parent
local humanoid = character:FindFirstChild("Humanoid")
local player = game.Players:GetPlayerFromCharacter(character)
local backpack = player:WaitForChild("Backpack")
local limit = 5
local limit2 = 10
local hadToolEquipped = false
humanoid.Died:Connect(function()
for i, tool in pairs(character:GetChildren()) do
if tool:IsA("Tool") and tool.Name ~= "axe" then
for _,v in pairs(tool:GetDescendants()) do
if v.Name == "TouchInterest" and v:IsA("TouchInterest") then
v:Destroy()
end
end
for _,v in pairs(tool:GetDescendants()) do
if v:IsA("ProximityPrompt") then
v.Enabled = true
hadToolEquipped = true
tool.Parent = game.ReplicatedStorage
end
end
end
end
end)
player.CharacterRemoving:Connect(function(character)
for i, tool in ipairs(backpack:GetChildren()) do
if tool:IsA("Tool") and tool:FindFirstChild("Handle") and tool.Name ~= "axe" then
task.spawn(function()
for _,v in pairs(tool:GetDescendants()) do
if v.Name == "TouchInterest" and v:IsA("TouchInterest") then
v:Destroy()
end
end
for _,v in pairs(tool:GetDescendants()) do
if v:IsA("ProximityPrompt") then
v.Enabled = true
tool.Parent = game.Workspace
tool.Handle.CFrame = character.HumanoidRootPart.CFrame
task.wait(15)
if tool.Parent == game.Workspace then
tool:Destroy()
end
end
end
end)
end
end
if hadToolEquipped ==true then
local equippedTool = game.ReplicatedStorage:FindFirstChildOfClass("Tool")
equippedTool.Parent = game.Workspace
equippedTool.Handle.CFrame = character.HumanoidRootPart.CFrame
end
end)
I don’t think you can remove TouchIntrest without removing the handle, as when there is a item named Handle inside the tool, it automatically applies it as a child with the said Handle
local character = script.Parent
local humanoid = character:FindFirstChild("Humanoid")
local player = game.Players:GetPlayerFromCharacter(character)
local backpack = player:WaitForChild("Backpack")
local limit = 5
local limit2 = 10
local hadToolEquipped = false
humanoid.Died:Connect(function()
for i, tool in pairs(character:GetChildren()) do
if tool:IsA("Tool") and tool.Name ~= "axe" then
for _,v in pairs(tool:GetChildren()) do
if v:FindFirstChild("Handle") then
if v.Handle:FindFirstChild("TouchInterest") then
v:Destroy()
end
end
end
for _,v in pairs(tool:GetDescendants()) do
if v:IsA("ProximityPrompt") then
v.Enabled = true
hadToolEquipped = true
tool.Parent = game.ReplicatedStorage
end
end
end
end
end)
player.CharacterRemoving:Connect(function(character)
for i, tool in ipairs(backpack:GetChildren()) do
if tool:IsA("Tool") and tool:FindFirstChild("Handle") and tool.Name ~= "axe" then
task.spawn(function()
for _,v in pairs(tool:GetChildren()) do
if v:FindFirstChild("Handle") then
if v.Handle:FindFirstChild("TouchInterest") then
v:Destroy()
end
end
end
for _,v in pairs(tool:GetDescendants()) do
if v:IsA("ProximityPrompt") then
v.Enabled = true
tool.Parent = game.Workspace
tool.Handle.CFrame = character.HumanoidRootPart.CFrame
task.wait(15)
if tool.Parent == game.Workspace then
tool:Destroy()
end
end
end
end)
end
end
if hadToolEquipped ==true then
for i,tool in ipairs(backpack:GetChildren()) do
task.spawn(function()
for _,v in pairs(tool:GetChildren()) do
if v:FindFirstChild("Handle") then
if v.Handle:FindFirstChild("TouchInterest") then
v:Destroy()
end
end
end
for _,v in pairs(tool:GetDescendants()) do
if v:IsA("ProximityPrompt") then
v.Enabled = true
tool.Parent = game.Workspace
tool.Handle.CFrame = character.HumanoidRootPart.CFrame
task.wait(15)
if tool.Parent == game.Workspace then
tool:Destroy()
end
end
end
end)
end
local equippedTool = game.ReplicatedStorage:FindFirstChildOfClass("Tool")
equippedTool.Parent = game.Workspace
equippedTool.Handle.CFrame = character.HumanoidRootPart.CFrame
end
end)
TouchInterest cannot have it’s .Parent property changed. :Remove() just clears data relating to the Instance and sets it’s parent to nil. Even if it does destroy it, another one would be created
I had this issue with my game, using :Remove() does remove the TouchInterest in my case.
local character = script.Parent
local humanoid = character:FindFirstChild("Humanoid")
local player = game.Players:GetPlayerFromCharacter(character)
local backpack = player:WaitForChild("Backpack")
local limit = 5
local limit2 = 10
local hadToolEquipped = false
humanoid.Died:Connect(function()
for i, tool in pairs(character:GetChildren()) do
if tool:IsA("Tool") and tool.Name ~= "axe" then
for _,v in pairs(tool:GetChildren()) do
if v:FindFirstChild("Handle") then
if v.Handle:FindFirstChild("TouchInterest") then
v:Remove()
end
end
end
for _,v in pairs(tool:GetDescendants()) do
if v:IsA("ProximityPrompt") then
v.Enabled = true
hadToolEquipped = true
tool.Parent = game.ReplicatedStorage
end
end
end
end
end)
player.CharacterRemoving:Connect(function(character)
for i, tool in ipairs(backpack:GetChildren()) do
if tool:IsA("Tool") and tool:FindFirstChild("Handle") and tool.Name ~= "axe" then
task.spawn(function()
for _,v in pairs(tool:GetChildren()) do
if v:FindFirstChild("Handle") then
if v.Handle:FindFirstChild("TouchInterest") then
v:Remove()
end
end
end
for _,v in pairs(tool:GetDescendants()) do
if v:IsA("ProximityPrompt") then
v.Enabled = true
tool.Parent = game.Workspace
tool.Handle.CFrame = character.HumanoidRootPart.CFrame
task.wait(15)
if tool.Parent == game.Workspace then
tool:Destroy()
end
end
end
end)
end
end
if hadToolEquipped ==true then
for i,tool in ipairs(backpack:GetChildren()) do
task.spawn(function()
for _,v in pairs(tool:GetChildren()) do
if v:FindFirstChild("Handle") then
if v.Handle:FindFirstChild("TouchInterest") then
v:Remove()
end
end
end
for _,v in pairs(tool:GetDescendants()) do
if v:IsA("ProximityPrompt") then
v.Enabled = true
tool.Parent = game.Workspace
tool.Handle.CFrame = character.HumanoidRootPart.CFrame
task.wait(15)
if tool.Parent == game.Workspace then
tool:Destroy()
end
end
end
end)
end
local equippedTool = game.ReplicatedStorage:FindFirstChildOfClass("Tool")
equippedTool.Parent = game.Workspace
equippedTool.Handle.CFrame = character.HumanoidRootPart.CFrame
end
end)