How To Utilize Scripts To Make A Magic Attack And It's Hitbox

How could i effectively utilize scripts to make a magic attack and what would be the best method to do hit detection. As far as i’ve seen it’s done by getting inputs from a local script and the ability itself on a server script and hit detection has been .touched but by using that method there’s a decent delay between the input and the ability, and .touched doesn’t work well with small and fast parts.

The best methods are:

“Raycast Hitbox Module,”
Raycasting,
Magnitude,
Region3 or the brand new partbounds.

All of these have different uses depending on what you’re doing, but take that statement with a grain of salt because they’re not entirely situational.

Raycast hitbox module is good for accurate hitboxes for games like Mordhau, magnitude is undoubtedly the best for performance overall ESPECIALLY close combat. Region3/PartBounds and raycasting I’ve seen used primarily for ranged abilities as well as close abilities, though all of these are amazing used correctly though.

P.S. Don’t use .touched for anything that you want to be accurate. Who doesn’t wanna be accurate?

1 Like

Thanks for the info, would you also happen to know how to use scripts without getting a delay ?

Yeah, utilizing optimal methods shortens that noticeable delay. Though a delay will always be there due to how clients and the server communicate, the goal is just to make it as unnoticeable as possible.

I personally do my hitbox detection with magnitude on the CLIENT, and have the server check what the client is sending is true, and it’ll damage. This method is great for the person hitting, as on your screen you got to them, but due to server replication it’ll show up a little wonky sometimes for the person being hit. For them you’ll seem further than you actually are but at a minuscule amount.

You can also choose to do it on the server, which technically makes it fair for everyone involved, but server replication makes it miss weirdly, when on your screen it’ll look like it hits. All these examples are extreme, and done right either way the game can be totally enjoyable because usually there is only a 0.2/ms delay. (From what I heard.)

What about visuals, where do you do those, also on the client ?

Yeah I do most visuals on the cleint and fireallclients() for it to replicate to the others.

May i also ask how exactly do you use magnitude for a hitbox, do you get all the possible hits in a table and then loop magnitude on all of them until magnitude is under a certain value then deal damage ?

  for i,v in pairs(workspace.Living:GetChildren()) do
        if v:FindFirstChildOfClass('Humanoid') then
            local dist = (pos - v.HumanoidRootPart.Position).Magnitude
            if dist <= radius then ...

Would i also have to put that in a while true do loop while i want it to be active ? Also what is workspace.Living, is it a folder in workspace, which has all of the entities ?

Nah, you don’t need to put it in a loop, once the desired situation happens, the script will run. Also, you’re right on dot with workspace. Parent all of your players/mobs to this folder and the script will ONLY check through that folder instead of searching through the entire workspace, which can contain thousands of parts.

P.S sorry for the late reply, I haven’t been on devforum for a bit