Region3 doesn't have correct position

I was trying to make a hitbox in region3 and checked if the region was correct or not. But this is what its like.

image

for some reason the region is flipped. The length and width are reversed. I tried changing the order of the regions but obviously that didn’t work. Anyone got a idea on what I did wrong or how I can fix this? Thanks in advance! :smiley:

Code:

local region = Region3.new(script.Parent.Position - script.Parent.Size / 2,script.Parent.Position + script.Parent.Size / 2)

local visibleregion = Instance.new("Part",workspace)
visibleregion.CFrame = region.CFrame
visibleregion.Size = region.Size
visibleregion.Transparency = 0.5
visibleregion.Anchored = true
visibleregion.Material = "Neon"
visibleregion.Color = BrickColor.new("Really red")

The only thing I could see happening would be that the “bone” is a mesh and you’ve messed up the size values for that. Make the part in workspace visible and check if that lines up with the region3.

You probably rotated your bone mesh. Region3s have an orientation of 0, 0, 0. If your mesh has an orientation different than 0, 0, 0 then it would cause this “issue” to happen.

I would recommend using the CFrame of the part and not the CFrame of the Region3.

Region3 is also being supersided by SpacialQuery, which does allow you to create Region3 like objects but with the added benefit of being able to rotate it using CFrames.


https://developer.roblox.com/en-us/api-reference/function/WorldRoot/GetPartBoundsInBox

local query = workspace:GetPartBoundsInBox(bone.CFrame, bone.Size)

I recommend using workspace:GetPartBoundsInBox rather than region3, as it does basically the same but with a CFrame value instead, meaning it works with rotations. Most region3 functions were deprecated anyways, so i recommend learning to use this