How to Efficiently Handle Damage Detection and Ability Management for Custom Models?

I’m working on a game that features a large number of custom models, including creatures like SCPs, animals, and other unique entities. Each model has its own setup, and I want to implement keybind-triggered attacks (like biting) that deal damage.

Here’s what I’m currently trying to solve:

Damage Detection

I’ve been experimenting with using raycasting from the model’s HumanoidRootPart to detect hits, but due to differences in model heights and structures, it hasn’t been very reliable. I’ve heard about using hitboxes instead, but I’m unsure how to set them up efficiently across all my models. How can I create and manage hitboxes that account for these height differences and ensure consistent damage detection?

Welding and Anchoring Hitboxes

I understand that hitboxes need to be welded to the model to move with it, especially during animations or when interacting with physics. However, I’m a bit confused about how welding interacts with anchored parts. If a part is anchored, does it affect the hitbox or the model’s ability to move? How should I handle the welding of hitboxes to ensure they work correctly without messing up the model’s movement or animations?

Ability Management

I’m also interested in learning how to effectively script abilities for these models, like triggering a bite or slice attack with a key press. How should I structure the code to manage cooldowns, detect hits, and apply damage efficiently? If anyone has tips or examples of how to manage abilities, especially with hitboxes or similar setups, that would be really helpful!

Summary:

  • How can I efficiently set up hitboxes for reliable damage detection across different model heights and structures?
  • What’s the best way to handle welding and anchoring for these hitboxes to ensure they follow the model correctly?
  • How should I manage and script abilities (like attacks) for these models, considering cooldowns and hit detection?

I’d appreciate any advice, scripts, or best practices you can share. Thanks in advance for your help!

You wanna create a part that will function as the hitbox in front of the character who activated it. Also I don’t think it needs to move as it’s only momentary, but there is a way to let it move which I will talk about later. As for doing this on the client or server, you are recommended to do this on the client to reduce lag on the server but you need to take steps to protect against exploiters

Like I said earlier, the hitboxes don’t need to move unless its an ability that needs it to move. Just to be safe, ill guide you on how to let it move:
You want to parent it to the workspace but weld it to the character’s humanoidRootPart as that is the part in the character that handles movement. They should not be anchored to let them move in accordance with the humanoidrootpart.

Tables. Just tables. You want to have a table to store the time the abilities were activated. Topic about that here

2 Likes

You can ensure by using a variable related to height like model:GetBoundingBox()

Avoid welding use CFrame instead.

If you still use welding you have to consider root priority to make sure the root part stays the same which is essential for animations and avoid anchoring.

Structure is just organization and tables as @MysteryX2076 said, be prepared to make lots of changes.

You can use a utility module to help so you dont have to deal with a lot of requires and makes reparenting and renaming the modules easier which is my current problem that I have to fix for my game in order to better organize it.

Quenty is a good example of handling a lot of modules in your game with a module loader to automate requiring modules.

1 Like

Thanks a lot guys, I’ll try all of that!