Raycast Hitbox 4.01: For all your melee needs!

I think that hitbox still looks a bit too small. But if you’re are still having problems, perhaps you can try sending me a barebone version of your place with the animations and rig so I can diagnose it further for you.

1 Like

Oh I actually think I managed to fix it by using :HitStop() a bit after the time the animation stops at bc I didnt encounter any more issues after that but since the red ray actually passed in my recent version through the arm I think there might be still an issue, not sure, but for now it seems to have been fixed and that the issue was on my part bc I used :HitStop() too soon
I’d still like to send you the place so if I missed anything you’d be able to point it out, I’ll dm you it.

3 Likes

Hi, Swordphin123!

Thank you for updating the module.
I also think you should put the Module on Github so we can help you maintain it!

2 Likes

Can I just pass a MeshPart (which in my game is the weapon) or do I have to pass a model with the Weapon inside?

I’d suggest using it on both, this may sound funny.
You should use it on the client for all of the effects, and such. Have the server process the actual stuff to make sure it’s a legitimate attack.

1 Like

My later replies do recommend using it on both or a hybrid of sorts. Not a funny, its totally a thing and I agree with you!

@RuizuKun_Dev I’m not actually sure how to use github. If I find the time, I definitely will put it up!

@DorksuRBX Any instance will do.

Any idea why mine isn’t working? The OnHit function never runs. The code below runs every time the Player left clicks.


image

  1. Have you first confirmed the debug rays to be drawing? Anything unusual in the output?
  2. Is there a reason you are deinitializing the hitbox? This will invalidate HitStart and HitStop the next time you use them, making them no longer work. Unless this attack only happens once, I would just recommend leaving HitStop in only.
local Hitbox = RaycastHitbox:Initialize(Character.Weapon, {Character})

Removing the second argument fixed the issue, so I assume the second argument is a whitelist (your API says it’s an ignorelist but that doesn’t seem to be the case).

And I deinitialize the Hitbox bc of how I’m handling my combat.


P.S I’d suggest making it so that we can choose if we want to see your Warns or not - I’ve commented all of them now as I don’t need to see them anymore. If Debug is true, the Warns should be outputted, if Debug is false then they shouldn’t.

The second argument is a blacklist. You can confirm this by looking at the raycastParams in hitbox object. That really shouldn’t be affecting it unless your “character” has all the enemies grouped together.

Seems to be fixed now, not sure why it wasn’t working properly before.

1 Like

Hey I only really have one question/problem how did you get the rays to follow the sword with a dash? (EX: image )

When I try using body velocity for a dash the rays stop before reaching the end, and I stop the casting right when the animation ends. (EX: https://gyazo.com/9f43378d5384184a6d7498c8b46ad706 )

3 Likes

Are your rays server or client sided? Normally this only happens if your rays are server sided. Its because the server has a slight delay on where the actual player position is. My NPC doesn’t have that problem because his rays and his actual model is already on the server so they will always be in sync.

Try making the hitbox longer (maybe past the length of your legs). The sword hitbox has rays being drawn slightly ahead of as well.

2 Likes

Yep the problem was the rays being server side, I spent time changing it and now they follow well, only concern is potential lag due to the rays somewhat spamming Remote Events, but should be fine.

2 Likes

Hey man, Im using your module and the raycasts are going all crazy. The HitBox only fires sometimes and is inconsistent. I already tried to extend the time until HitBox:Stop() fires but i get the same results. Any ideas?

local Damage = 30
local RayHitBox = HitBox:Initialize(Character,{Character})


RayHitBox.OnHit:Connect(function(hit, oppHum)
	print(hit.Parent.Name)
	oppHum:TakeDamage(Damage)
end)
vPunch1:GetMarkerReachedSignal("Start"):Connect(function()
	FaceOpponent()
	RayHitBox:HitStart()
end)

vPunch1:GetMarkerReachedSignal("Ended"):Connect(function()
dPunch1 = false
Continue = false
RayHitBox:HitStop()

end)

2 Likes

How are your attachments setup? It merely follows the attachment instance position (or setpoints position). Verify you aren’t moving the attachments away in the workspace while you are playtesting.

1 Like

They run along my arms as you would expect. I even made the fist attachments stick out just to make sure they would hit the npc, but they don’t. Also they do not move unexpectedly during playtesting.

1 Like

Can you DM or share the model to me containing the attachments? Your code looks fine to me.

1 Like

Debug toggle seems to not work?
https://gyazo.com/31891be42c6f3f04d95b702c2e4864b9

My code:

local HitboxMod = require(game.ReplicatedStorage.Modules.RaycastHitbox)

local Debug = false

script.Parent.TextButton.MouseButton1Click:Connect(function()
	if Debug == false then
		Debug = true
		script.Parent.TextButton.Text = "Debug: On"
		HitboxMod:DebugMode(true)
		
	elseif Debug == true then
		Debug = false
		script.Parent.TextButton.Text = "Debug: Off"
		HitboxMod:DebugMode(false)
	end
end)
1 Like

DebugMode has been changed since 2.0. The new variant is initializing a hitbox first and then calling DebugMode on that. This ensures that you can turn on/off debug rays for specific hitboxes instead of universally enabling it on all of them.

local HitboxMod = require(game.ReplicatedStorage.Modules.RaycastHitbox)
local MY_HITBOX = HitboxMod:Initialize(SwordExample, {Character})

local Debug = false

script.Parent.TextButton.MouseButton1Click:Connect(function()
	if Debug == false then
		Debug = true
		script.Parent.TextButton.Text = "Debug: On"
		MY_HITBOX:DebugMode(true)
		
	elseif Debug == true then
		Debug = false
		script.Parent.TextButton.Text = "Debug: Off"
		MY_HITBOX:DebugMode(false)
	end
end)

However, if you are still using V1.0+, it should still work the way you are doing.

1 Like