Raycasting from inside part (hitbox)

I am having difficulty casting rays in my combat system. I have a transparent non-colidable part that surrounds the character to make them easier to hit. I want to be able to raycast from outside and inside of this part. If I go inside of the part my raycast doesn’t work.

Here is an illustration of what i’m trying to do (be able to hit the hitbox from outside of the hitbox, and the hitbox/player parts from inside of the hitbox)

1 Like

IIRC, you can choose to blacklist certain parts from a raycast. If you set the hitbox of the player that is shooting to the blacklisted part, it should do what you want. Ill see if I can find information on blacklisting

edit: Raycasting | Roblox Creator Documentation

1 Like

Okay so everyone has this big box around them.

Lets say player1 fires a shot at player2. Player1 already adds the hitbox to a blacklist before firing the ray.

If I try to add the other persons hitbox to the blacklist, I then have to know information I dont have; am I inside of that players hitbox?

Maybe I can do a touched event on the hitbox part and enable/disable it based on that. Might be my best solution

So when you’re outside the player’s hitbox, you shoot the hitbox to hurt the player, but when you’re inside, you want to disable the hitbox? Why, may I ask? It’s a hitbox. How big is the hitbox?

Because the hitbox is there for the purpose of making it easier to hit a person while raycasting.

So if im very close to the player (inside of the hitbox) i still need them to take damage.

Hitbox is (20, 20, 20)

You can try using magnitude to see if the Raycast origin is already inside of the hitbox, if it is, then you don’t need to raycast and you can just skip to dealing damage.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.