How can i change HingeJoint's axis from code?

I want to change HingeJoint’s z axis when click on screen but i dont know how to do it. I tried to do it from “GetComponent.axis.z = -1;” or “GetComponent.axis = Vector3.left” but both of them didnt work and in Unity’s scripting API says “Joint.axis” but i dont know how to use it.

Thanks for help.

Unless the editor ate some of the code you wrote above, the problem is your code isn’t using GetComponent correctly. Just look up any example of using GetComponent. May also need to look up any example of setting Vectors (you often have to set all parts at once, like your 2nd “left” example.)