Limiting the X and Y of a rotation to 0

I cant figure out how to do it. Whenever i collide into another game object it sends me spinning on the x and y axis. My game is clamped on the y axis and that stays at 0. my controller for the player uses the Y rotation so this code below doesnt work because then i cant turn my player:

	void Update () {

		float yMovement = (turnSpeed * 20f * Time.deltaTime * Input.GetAxis("Horizontal"));
		

		transform.Rotate	(0,yMovement,0);
		transform.rotation = Quaternion.Euler(0,yMovement,0);
	}
}

Do you want to register the collisions at all? If not, you could just avoid it entirely by using Unity’s layer-based collision matrix:
Layer-based Collision Matrix

That would allow you to selectively prevent other objects from colliding with the player, each other, etc…