Make a part disappear when a part touches it

I watched a tutorial on youtube where he adds it on “else” but when i added Sword:Destroy() it did not destroy it when it touched the floor


		Sword.Touched:Connect(function(Hit)
				if Hit:IsA("BasePart") then
					if not Hit:IsDescendantOf(Char) then
						local Humanoid = Hit.Parent:FindFirstChild("Humanoid")

						if  Humanoid then
							Humanoid:TakeDamage(5)		
							Sword:Destroy()	
								
							else
						end
					end	
				end
			end)

You put Sword:Destroy() in the wrong spot. Here is a correct script:

		Sword.Touched:Connect(function(Hit)
				if Hit:IsA("BasePart") then
					if not Hit:IsDescendantOf(Char) then
						local Humanoid = Hit.Parent:FindFirstChild("Humanoid")

						if  Humanoid then
							     Humanoid:TakeDamage(5)									
						else
                                Sword:Destroy()	
						end
					end	
				end
			end)

It does this
robloxapp-20220503-1554310.wmv (1.7 MB)

Should it be destroyed when it hits a player as well as when it hits the floor?
If so:

Sword.Touched:Connect(function(Hit)
				if Hit:IsA("BasePart") then
					if not Hit:IsDescendantOf(Char) then
						local Humanoid = Hit.Parent:FindFirstChild("Humanoid")

						if  Humanoid then
							     Humanoid:TakeDamage(5)				
                                 Sword:Destroy()						
						else
                                Sword:Destroy()	
						end
					end	
				end
			end)

This happens
robloxapp-20220503-1604583.wmv (896 KB)

Can you show us full script please?

Its in the workspace

		local Sword = FX.Sword:Clone()
		Sword.Parent = workspace
		Sword.CFrame = HumRP.CFrame * CFrame.new(math.random(-50,50),math.random(1,15),2)
		Sword.CFrame = CFrame.new(Sword.Position,MouseHit.p)			
			Hand:Play()