Just FYI there’s also Vector3.FromNormalId, so you can replace all that with axis = Vector3.FromNormalid(face).
To fix your actual problem, you can check if the position where the object would end up is valid and then not move it unless that’s the case. Here’s a different response showing how you can check if one AABB is contained within another, which you could use for your check:
You can get the X and Z position value for each border and then clamping the part’s X and Z position to the minimum and the maximum using math.clamp.
You have to check the corners of every part and then see if it’s outside of the border. The solutions here say just to check the part’s position and clamp it inside of the border but that’ll still allow the part to clip outside of it.
If you have rotating, I suggest checking all 8 corners and clamping them to prevent any clipping.