In 2d Gameplay Tutorial

Where does the script that will prevent Z-axis?

There’s no script for it.

You add a configurable joint to the gameobject and then lock Z Motion, Angular Motion X, Angular Motion Y.