Raycast Hitbox 4.01: For all your melee needs!

An example of basic sanity check is: make the client do all the hit detection with this module. Once the client hits a humanoid, send a remote event to the server essentially telling the server to damage this humanoid it hit.

The server won’t immediately damage the humanoid. Instead, it will verify first if it is valid. A simple way is to do a raycast between the hit humanoid and the player that called the remote event. If there is a wall between them, don’t damage the humanoid (because you’re not suppose to damage stuff through walls anyway!) Another sanity check you can combine it with are magnitude/distance checks. If the player says to damage a humanoid but that humanoid is 500 studs away, this is already a red flag. It’s basically just seeing what makes sense in your game and making sanity checks according to that. I recommend searching around the devforum as well for what makes good server side security against exploiters.

4 Likes

So I would send my own raycast, not using your module, to check if there is an object between the two?

1 Like

Correct. Once the server validates that all your checks are 100% okay, then it will deal the damage.

2 Likes

Hello! I’m here to ask on how it works, because I’d like to make my own one so I can understand the script. I used to use touch event which is know for being a unreliable way to do so, so I wanted to try this, but i can’t find any examples of how it functions. Thank you in advanced!

2 Likes

Why Raycasting over Touched, Region3, etc… ?

In all honesty, I have never heard of developers using Region3 as a hitbox for melees. I’ve just started learning the basics of Region3, and that sounds insanely complicated and too complex.

It makes sense given what it does, but it just sounds like too much work and impractical.

Region3 is fast but cannot be rotated (egomoose cough)
Touched is inconsistent and useless if you’re CFraming

1 Like

could you please post an example as to how you use linkattachments in a script?

im struggling so much right now… lol.

The sample roblox place provided in the original post has a link attachments example. I wouldn’t recommend using it over the normal raycasting system if you are using it for swiping melee attacks, but it has its niche cases.

An example code can be:

local RaycastModule = require(RaycastHitboxModule)
local Hitbox = RaycastModule:Initialize(workspace.Part)

local Attachment1 = Instance.new("Attachment", workspace.Part)
local Attachment2 = Attachment1:Clone()
Attachment2.Position = Vector3.new(0, 20, 0)
Attachment2.Parent = workspace.Part

Hitbox:LinkAttachments(Attachment1, Attachment2) --- Links a raycast location between the two attachments

Hitbox:HitStart() --- Starts the damage logic, will continually raycast between the two points defined above
2 Likes

thanks i apreciate it.

this is actually what i made using linkedattachments:

https://i.gyazo.com/5698dc36f0a36ebe63b7613aad9d780f.mp4

basic hand-hand combat, i felt that in this case linkedattachments would be more suitable for my needs… little did i know it came out better than i expected.

me and alot of others really appreciate this module, keep doing what you’re doing.

2 Likes

So, I was making this Module work with my game and I stumbled upon something weird, in the API it says " RaycastHitModule:GetHitbox" but what is “RaycastHitModule” since when we’re talking about the main module, above it’s referred to “RaycastHitbox” I tried using the function GetHitbox() on the “RaycastHitbox” module but it returns a nil value, even though the hitboxes initialize successfully. Please help.

Its an old function that I forgot to add back in when I revamped the module. The newest version, v2.2 is available on my github that fixes the missing function so you can download it there. I will update it on the actual site soon.

Alright, thank you. I love the module btw, It’s really easy to adapt from old .Touched Hitboxes. :+1:

1 Like

Ok, so I stumbled upon another weird thing, when I initalize the hitboxes that I’m going to use, and call them using the :GetHitbox() function, it creates them again? I only call the initalize function once, and when I execute the attack it warns me that “This hitbox already exists”, even though it’s not initializing it again. I’m using Hitbox:HitStart() and Hitbox:HitEnd() only, so I don’t know what causes this issue. This glitch is very problematic, since it creates the Hitboxes, and they stack over and over dealing progressively more damage upon reaching the point of a one shot kill.

Doesn’t sound like an issue with the hitbox function but are you forgetting to disconnect the OnHit when you are done with HitStop()? You are creating a new thread when you run the connection line but it is difficult to diagnose if you don’t provide sample code.

1 Like

My bad, I didn’t know you had to disconnect it, it worked, thanks.

how could i make attachments go along the arm with this module? or is there a function for that (i think there is i just can’t find it)

Attachments are objects parented to parts that you can make beforehand (in studio) or with a script. They will always move relative to the part you insert them in. There are no functions in this module to make them for you. A user a while back posted an attachment resolution code that auto generates attachments in a line, which may be of help to you.

1 Like

i know what attachments are, i’m using this for fist combat and i was wondering how to make attachments go along the arm / fist; thanks for the help

This is really useful, thank you for making this hitbox Raycast open-source.

1 Like

Hello again, I’d like to know if this module is compatible with CanCollide false parts or CollisionGroups that dont collide with the default collision group. Thanks.