Object Rotation problem

Im making a 2D game and i want to allow the Controllable ship to rotate on the Z axis and the other locked on 0 but when ever i use Torque Z axis locked aswell as X,Y,Z

transform.rotation = Quaternion.Euler(0, 0, transform.rotation.z);

I can not see any problem with the code and its really getting on my nerves.

Why not just freeze the axes on your rigidbody? In the rigidbody inspector, under the ‘Constraints’ dropdown, use ‘freeze rotation: x, y’ to prevent your rigidbody from moving on those axes.