Detect when part hits part

How would I tell if a part touched another part. For example if “Block” hits “Block1” then print (“Hit!”)

local part1 = --part1
local part2 = --part2

part1.Touched:Connect(function(hit)
if hit == part2 then
print("Hit!")
end
end)

Another thing you can do, is in the part that is hitting, do the following.

local HITNAME = --name

script.Parent.Touched:Connect(function(part)
if part.Name == HITNAME then
– post your code here
else
print(“Not hit!”)
end
end)