problem with rotation clamp

tX = finger.ScreenDelta.x;
tY = finger.ScreenDelta.y;
primaryWeapon.transform.Rotate(new Vector3(-tY * primaryWeaponAgility * PlayerPrefs.GetFloat(“ScopeSens”) * Time.deltaTime, tX * primaryWeaponAgility * PlayerPrefs.GetFloat(“ScopeSens”) * Time.deltaTime, 0));
primaryRotationX=Mathf.Clamp(primaryWeapon.transform.localEulerAngle.x, -6f, 6f);
primaryRotationY=Mathf.Clamp(primaryWeapon.transform.localEulerAngles.y, -36f, 36f);
primaryWeapon.transform.localRotation=Quaternion.Euler(primaryRotationX, primaryRotationY, 0f);

I’m using this script to rotate my weapon object which a child of the player object
the rotation happens every frame based on the touch input
the script works fine except the part where its supposed to clamp the rotation of the weapon to stop it from facing the player.
Now this part only works for the right and top rotation and not for bottom and left rotation
Please suggest any possible solution to this problem as i’m unable to solve it by my self
any suggestions and ideas would be really appreciated
Thanks

i 've an idea of clamping the rotation respecting the player(parent)'s transform.forward .
what i mean by that is to keep track of( primaryWeapon.transform.forward - parent.transform.forward)
and if it exceed threshold or -threshold u just stop it from rotation

@aminbenslimen00
That isnt working as well because the rotation is not going to +36 and -36 it going from 360 to 320 on the left side