I made it so a tool stays equipped until the weapon is finished firing but after the player dies, unequipping it causes it to disappear completely

Bit of a long title so I won’t repeat myself, this is how the script looks like:

script.Parent.Activated:Connect(function()
	if deb == false then
		deb = true
		canUnequip = false
		
		script.Parent.Fire:Play()
		
		wait(1.25)
		
		script.Parent.Fire:Stop()
		
		
		
		local pos = script.Parent.Parent.Humanoid.TargetPoint
		local LookAt = (pos - script.Parent.Parent.Head.Position).Unit
		
		
		
		script.Parent.BigBomFired:FireServer(LookAt)
		
		canUnequip = true
		
		wait(5)
		deb = false
		
	end
end)

script.Parent.Equipped:Connect(function()
	
end)

script.Parent.Unequipped:Connect(function()
	if canUnequip == false then
		wait()
		Humanoid:EquipTool(script.Parent)
	end
end)

Your issue is that when someone is dead and if they unequip it while dead, it will disappear?
Try doing this.

script.Parent.Unequipped:Connect(function()
	if canUnequip == false then
        if Humanoid.Health>0 then
	    	wait()
	    	Humanoid:EquipTool(script.Parent)
        else
            script.Parent.Parent = workspace -- You may also need to move the tool to the dead body in the script, but I think this will suffice.
        end
	end
end)

Didn’t seem to work, I get “Something unexpectedly tried to set the parent of Tool to Workspace while trying to set the parent of Tool. Current parent is Backpack”

Also, What do you mean by moving the tool to the dead body?

Alright, well my guess is that you can’t equip a tool to a dead humanoid. You might need to wait before setting the parent to solve the current issue. You may need to move it if for some reason it does not appear next to the body when you parent it to workspace. The downside of this is that it won’t despawn when the player despawns. You may be able to parent it to the character rather than using EquipTool, so it still disappears.

1 Like

Oh, I found out that just destroying the tool works, thanks for helping.

1 Like