Why doesn't it remove the touch interest

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

1 Like

Did it with handle didn’t worked

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)

If i would remove the handle I would remove the entire tool the mesh the scripts maybe that would be not that clever XD

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 believe the TouchInterest is auto generated due to the fact the object’s CanTouch is set to true.

But if I do cancollide to false the proximity doesn’t work

CanTouch = false … go look at what that will do. Same as Destroy()

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)