# Help With Region3 Hitbox

You can write your topic however you want, but you need to answer these questions:

1. What do you want to achieve? Keep it simple and clear!
Hey, I’m trying to create a hitbox for which is just in front of my player using region.
The problem is my maths. Right now it works, but the hitbox (pink) is like this

when it should be like this
``````local region = Region3.new(char.HumanoidRootPart.Position - Vector3.new(2,2.5,0), char.HumanoidRootPart.Position + Vector3.new(2,2.5,3))
``````

I have tried changing the values in here for a while now to move the hitbox, but I just can’t get it to work. So how can I fix this?
note: I’m unable to change the region3’s CFrame, as it is a read-only value.

4 Likes

Well, to get the bottom left corner you can do this by making the position relative to the orientation of the Character using CFrames:

``````local characterCFrame = char.HumanoidRootPart.CFrame
local cornerPosition1 = (characterCFrame*CFrame.new(-Vector3.new(2,2.5,0))).Position
local cornerPosition2 = (characterCFrame*CFrame.new(Vector3.new(2,2.5,3))).Position
local region = Region3.new(cornerPosition1,cornerPosition2)
``````

I’m not sure it’ll work but that’s the gist of CFrame multiplication. However you will find that the region3 won’t be rotated like the second image as Region3’s cannot be rotated especially if the character is facing diagonally. To solve this you can use the RotatedRegion3 Module.

2 Likes

This pretty much works, but it makes the region behind the player instead of infront. How can I fix this? I’ve tried switching positive values to negative and vice versa but it doesn’t seem to work.
https://gyazo.com/2863306521bd6c18357a2cfc932b4e3c

Hmm, honestly I would play around adjust the values more, however, this time use a region3 visualizer to debug the problem since it’s hard to tell looking at the gif provided by using the following code:

``````local Debris = game.Debris--get the service

local regionVisualizer = Instance.new("Part")
regionVisualizer.Name = "rV"
regionVisualizer.Anchored = true
regionVisualizer.CanCollide = false
regionVisualizer.Size = region3.Size
regionVisualizer.CFrame = region3.CFrame
regionVisualizer.Parent = workspace