Raycast Hitbox 4.01: For all your melee needs!

Is the raycasting done on the server as well? Are the animations of the model being played on the client or is the client sending its input to the server which makes the model play its animation?

The only thing that is on a local script is inputs which then fire remote events to the server, which then does everything else
animations are on the server as well

Try setting the model’s primarypart network ownership to the server.

PrimaryPart:SetNetworkOwner(nil)

The animations might not be replicating properly on the server since its close to the player. Are you using attachments or setpoints to create the raycasting?

attachments, I’ll try that then

Unfortunately did not work, any other ideas?

You can use #help-and-feedback:scripting-support showing all relevant code and rigging to get more in-depth help, to avoid clogging up this topic. (your problem is not really relevant to anyone else reading this topic)

3 Likes

Whats the best way to use this module for square hitboxes? Like a rock? I was thinking on adding attachments to every face of the rock but it dont seems be very good to performance.

You can run hundreds of rays a second without affecting performance one bit. Creating rays in of itself are very cost efficient and you shouldn’t worry about that.

What you should be worried about is how far the rays will be shooting. 1000 rays that shoot 1 stud is better than 100 rays that shoots 100 studs. So unless your rock is going 100 miles an hour, you shouldn’t worry about performance.

However, for your specific problem, I would consider going back to touched, region3, or my personal favourite, using :GetTouchingParts

5 Likes

Thanks for explanation! I think I will still use your module because I like it very much and it works nice for me. And I consider raycasting better than the others hitboxes ways. And as the rock wont be moving (its not a projectile), I think its fine.

1 Like

In my personal experience, for the people that have double sided weapons (like me): I’m pretty sure putting the attachments down through the middle of the weapon should work, because that way, you always land a hit - regardless of which side of the weapon hit. Works best for swords.

The raycast hitboxing works off for me. My friend has found an issue regarding the hitboxing: for some reason, the hit rays can damage the player that casted them - resulting in the player sometimes getting hurt by their own sword.
Here’s a gif of that happening:

https://gyazo.com/4d72d64c8c24c8ce3dc7bca025fc9a54

Do you have any clue what could be the cause of this? And how to fix it? I thought something like this wouldn’t have been an issue. No changes were made to the module – I followed the instructions (with the connection/disconnect variable function) and this started becoming a problem just now.

The supplied Initialize function includes an ignore list. Use that and the rays won’t register it. If it still damages the character, you might have something else interfering.

local Hitbox = Raycast:Initialize(Weapon, {Player.Character}) ---Ignores character
6 Likes

Do we need to clone the module for each weapons? I opened the showcase and you have multiple modules for each objects.

What? You only need 1 module and then require it on each weapon.

You don’t need 3 modules if you have 3 weapons, Only 1.

Got it, was just wondering since he added multiple modules on the showcase

1 Like

Why i am getting the player being damage multiple time ? i used a deb but it doesnt work either

If you are running OnHit on a loop (or if you are basically creating OnHit without disconnecting it afterwards) then it will lead to this.

The best way to counter that is doing it like this

local HitboxConnection = nil
HitboxConnection = Hitbox.OnHit:Connect(function()
     --- code here
end)

---Once we are done, disconnect the hitbox
HitboxConnection:Disconnect()

Ok it worked i did that when i touched , i damage and after i disconnect so its only doing damage to a single player . But if i want to make it like it damage everybody that the ray touch just a single time ?

The rays already will only hit once per target if that is what I understand. You can hit multiple targets but OnHit will only call once for each of those target.

	local HitboxConnection = nil
	HitboxConnection = HitBox.OnHit:Connect(function(hit,humanoid)
		humanoid:TakeDamage(10)
		HitboxConnection:Disconnect()	   
	end)

idk why but sometime it one shot some mob for no reason . It make multiple damage . There is like 2 attachment of dmgpoint in the arm .

I would recommend leaving the HitboxConnection:Disconnect() outside of the function, or at least have a fallback disconnect system. That block of code will only disconnect the OnHit connection when it registers a hit. What will happen if it misses a target? The OnHit is still active.