Need help with this equation

I’ve made an equation that will help decide if an item is placed out of bounds. However, you can’t place items in the corners, and around the edges. It will think its out of bounds.

I’ve already written what I thought would work, I might have messed up something but it should be working.

						tempitem:SetPrimaryPartCFrame(location)

						local extentsCheck
						
						local hitbox = tempitem.PrimaryPart -- hitbox object
						local pos = location.p -- placement position
						
						local extents = {}
						
						extents.x = pos - (hitbox.Size / 2)
						extents.z = pos + (hitbox.Size / 2)
						
						extents.bx = truebase.Position - (truebase.Size / 2)
						extents.bz = truebase.Position + (truebase.Size / 2)

						if (extents.x.x < extents.bx.x) or (extents.x.x > (extents.bx.x + truebase.Size.X)) or (extents.z.z > extents.bz.z) or (extents.z.z < (extents.bz.z - truebase.Size.Z)) then
							extentsCheck = true -- outside of bounds
						end

The orientation of the base is (0,0,0) so its not a problem with rotation. I can’t seem to figure out what the problem is, so if you see it please let me know.

So, you are checking to see if an item is out of bounds huh? Well, so if an item is on the edge, it says it is out bounds? Is the script not working?

The script is working in that its not allowing people to place out of bounds, but it makes it so you can’t place near the edges either. I’ve figured out that it comes down to the first part of the equation

This part seems to be where the issue is happening, but I’m not sure why.

It seems to only happen to items that have a hitbox that aren’t the same on X and Z. It happens fairly often on an item with a size off, like X:30 Z:3

It could be that my script to get the X and Z of the item is doing it, but I’m not sure how I would improve it.