Oscar21 - The advice above is sound, but it's for a pre-facelift car with M54 engine - if that describes your car, you can ignore the rest of my post.
For a facelift (N52 engine, 2006+) car, the job is similar, but the detail differences could be frustrating, if not expected. On an N52 engine, consider changing the oil cooler gasket and the "Mickey Mouse flange" coolant hose at the same time. And you'll need slightly different tools. Here's what I did some months ago: https://z4-forum.com/forum/viewtopic.php?p=1985350&hilit=OFHG#p1985350