The rigidbody is 3d. and i want if i enter a collision, the xyz positions are freezed.
You can either destroy the Rigidbody so the object stops moving, or else set all the constraints to prohibit moving and rotation. It depends if you want that exact object to keep going again later.
Huh? i need the freeze xyz throught the script.
That’s what my answer is for.
Look for Destroy() documentation.
Look for Rigidbody constraints documentation.
Use Rigidbody constraints: