CFrame issues with a custom hitbox

I’m trying to make a custom hitbox for a combat tool and so far, it works, except it has some minor problems that are stopping it from being fully finished and they’re both related to CFrame.

First issue I’m having is that I want the brick (hitbox) to be infront of the player whenever m1 is pressed, rather than being IN the torso. So, vector3.new would easily fix that right? Well, no, cause adding a Vector3.new completely breaks the brick’s rotation.

This is the code and an image of what it does currently


image

It works but I want the brick to be in front, not in the centre of the torso.

The 2nd problem has to do with the player teleporting around whenever m1 is pressed. For example, I can be moving my avatar but as soon as m1 is pressed the hitbox is generated and the player gets sent back to where it was created. No, it’s not anchored as you can see in the code, but it still happens.

1 Like

you probably (maybe) wanna go for a CFrame.LookVector property instead. Cause I see that the hitbox is also rotated, and thats most likely cause you used CFrame.Angles to multiply the position property. So look into that maybe?

that worked. but do you have any clue on how I could fix the 2nd problem?

not quite sure but take a look at disabling CanCollide before you parent the parts to whatever you are parenting them, so you prevent that from happening

Instead of creating a CFrame based on the torso rotation and position, you could probably just use the existing CFrame and add an offset:

`fistHitbox.CFrame = torso.CFrame * CFrame.new(0, 0, -someForwardOffset)`

For your second problem, it’s because you are welding the hitbox to the character. I think for this case it would be easiest to just anchor the hitbox and not weld it to the character unless you really need it to move with the character - but you probably do not need to.

1 Like

well, you helped me fix one problem at least so, thanks. I’ll try to figure something out for the teleporting issue.

1 Like

My original plan was to have it follow the player around, but that seems to have no easy solution so I’ll try without welds.

For the 2nd problem just set massless of the hitbox to true. Also try using normal welds instead of weld constraints.