Raycast Hitbox 4.01: For all your melee needs!

Yes. While seemingly simple, I recommend familiarizing yourself with the limitations of localscripts. Overall, it shouldn’t take too much effort if you are already familiar with scripts in general.

1 Like

HI,
Relating to getting it going on the client side, after that is accomplished and some spoofing checks are added, what are some of the downsides of the limitations of localscripts, relating to this module that you are aware of?

Thanks

After using this module for a while, I found out that one of my lightsabers had this issue where the rays were casted in the incorrect spot. This only happened for the regular saber and I’m not sure what could’ve caused this, here’s some footage.

https://gyazo.com/ed895ae3c88a66b5df478b2b36cac72d

As you can see, the lightsaber is swung down, but the rays are casted to the left if that makes sense.

https://gyazo.com/bf3a4ed7c957a9a9f2b8514dbe33c5b2

Okay, so apparently tweeting the HRP caused this.

1 Like

I’m currently working on a new game, does this work with fists?

It works with any basepart. But for fists it might be better to use something like rotated region3.

1 Like

Hey i seem to have an issue with the rays not firing properly the first time a player swings his weapon
Video:

And here is the code

		elseif input.UserInputType == Enum.UserInputType.MouseButton1 and equipped and not debounce then
			debounce = true		
			local slashAnimTrack = animator:LoadAnimation(slashAnim)			
			local hitBox = RAYCAST_HITBOX:GetHitbox(character["Axe"].HitPart)			
			--DamageEvent:FireServer()		
			hitBox:HitStart()			
			slashAnimTrack:Play()			
			wait(slashAnimTrack.Length)			
			hitBox:HitStop()			
			debounce = false
		end

And this code here which is also in the same local script as the above code initializes the hitbox when the weapon is instanced.

function initHitbox(weapon, equipped)	
	if not equipped then
		local RayPoints = require(RS.RayPoints)	
		local char = player.Character	
		local ignore = {char}	
		local newHitbox = RAYCAST_HITBOX:Initialize(char:WaitForChild("Axe").HitPart, ignore)
		newHitbox:DebugMode(true)
		newHitbox:SetPoints(char[weapon].HitPart, RayPoints[weapon])


		newHitbox.OnHit:Connect(function(hit, humanoid)
			print('Damaged')
		end)
	end
end

If you have any idea what is causing this issue or if you need more information that can help you help me resolve this problem then please let me know thanks.

2 Likes

Had the exact same problem basically your using the length of the animation track but the animation track isnt loaded and by default its set to 0. You could use an animation event to try fix it I havent got round to solving mine yet.

2 Likes

God i feel like a complete idiot. The way i decided to fix it was to load the animation at the start of the script instead of at the start of the function. Thanks for the help!

2 Likes

You tweened the HRP? I feel like it should work perfectly normal but if you want the character to move just use a body mover.

Set the parent of the attachments you’re using the HumanoidRootPart. It doesn’t get affected by animations.

is it possible for u to put in the attachment tht detected it as a paramete

8 days later i just had the same issue, did u find a solution for it?

it is detecting the RayCastHitboxDebugPart when debug is on not a problem for me but might be for others

Try keyframe reached or marker reached might help but I didn’t solve it due to quitting that project

1 Like

mmm @TeamSwordphin u accidently marked the wrong post as solution

@crazygamer817 Thanks, haha just woke up and accidentally clicked it.

It’s possible, though is there a specific use case for why? The group feature can accomplish this, if you need one attachment specifically you can designate a group name for it.

There was an alternative solution which I personally use which often guarantees animations to not return zero length here:

1 Like

stuff like knocback etc getting position for hit effects etc. the grp thing needs unneccessary instances which cn get a bit laggy for me since i have a lot of weapons and also there r a lot of weapons and its like too much work, i cn like change the module for myself specifically too but thought this would be a useful feature

edit 1:

i feel u man except i make such mistakes cuz of no sleep

edit 2:
i for one am gonna be using this a lot in hit effects knockback calculations damaging etc etc. i am working on tht advanced sword combat system tht i might open source with limited features later

1 Like

I love the whole module, but I think the default name of hitpoints should be “Hitpoint” instead of “DmgPoint” because this doesn’t just have to be used for weapons.

I have a knife-throwing script, it works fine for damages, but I can’t seem to figure out how to get it to stop once it has hit a wall or something. Is there any way I could fix it? No errors in the output btw.

spawn(function()
	local Damage = 50
	local Hitbox = RaycastHitbox:Initialize(Knife, char:GetDescendants())

	Hitbox.OnHit:Connect(function(hit, humanoid)
		if donefor then return end
		print(hit.Name)
		if humanoid:IsA('Humanoid') then
			if humanoid.Health == 0 then return end
			if Instakill then humanoid:TakeDamage(humanoid.MaxHealth) else humanoid:TakeDamage(Damage) end
			Knife:Destroy()
			thri:Play()
			print('Humanoid')
		end
		local part1 = hit:FindFirstAncestorOfClass("Model")
		local part2 = yo1:FindFirstChildOfClass("Humanoid")
		if not part1 or part2 then -- check if it should be a wallknife (this is the part where nothing happens)
			Knife.Anchored = true
			Knife.Cancollide = false
			Knife.Name = 'WallKnife'
			knifeBV:Destroy()
			thri:Play()
			print('Wall')
		end
	end)

	Hitbox:HitStart()
	wait(3)
	Hitbox:HitStop()
end)

I’m going to go insane it says if not part1 or part2 oh my god I have been throwing at models god I strongly dislike life. I forgot to add “not”