I'm trying to freeze both position.x and rotation in Rigidbody2d in a script but i cant manage to freeze both of them. any ideas?

here are the commands i use:
GetComponent ().constraints = RigidbodyConstraints2D.FreezeRotation;
GetComponent ().constraints = RigidbodyConstraints2D.FreezepositionX;

It only gives me the choise to freeze position x and y or the rotation only or alla of them at the same time.

I just only want to have the position.y unchecked which i can do it manually in the inspector but not in the script.

Any ideas???

The constraints property is a Bitmask. Simply setting it to a single option only sets that option. You need to use the | (bitwise OR) operator to merge them together before setting it i.e.

constraints = RigidbodyConstraints2D.FreezeRotation | RigidbodyConstraints2D.FreezepositionX;