Object spins out of control

When I move my object called gun into another object called wall and they collide gun spins out of control into space. Both objects have box colliders and rigid body’s.

I would like for wall to act as a barrier so gun can not move out of bounds, and it dose but the spinning wildly into space is not a desired effect. Also I have tried freezing the rotation on the rigid body but then it just goes in a random direction on the x,y,z axis. Freezing position did not work either.

Thanks in advanced

Thanks for trying to help. I got the solution.

I removed the rigid body from the wall so it only had a box collider and the gun had a collider and a rigid body. When they collided nothing when flying into space.

This is probably why only the player should have a rigid body and not the scenery.