A toilet valve can cause a water hammer if it is not properly installed or adjusted. When the valve is turned off too quickly, it can cause a sudden change in water pressure, leading to the pipes banging and vibrating.