Raycast Hitbox 4.01: For all your melee needs!

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”

i just finished tht and am working on dmg calculations so well i kind of need a way to see how long the hitbox has touched the part and when it leaves and stuff is smthg like this possible if so could u gimme some sort of guidelines for doing so

Unfortunately not possible due to the nature of how raycasts work on Roblox. Rays only listens for intersections of parts and does not know whenever it has left or entered a part.

so wht if i set up a link between the top and bottom end and maybe set up a table for the parts it saw in the previous detection do another detection in between frames and if its not there now then it left. would smthg like tht work?

It might, though that will be up to you to implement it. The module automatically omits already-detected parts for performance reasons. This makes sure other rays don’t accidentally call its hit detection twice. If you don’t want the module automatically ignoring parts it has already hit (for example, might be good for your use case), you can look at the MainHandler script in the module, and commenting out

Object.targetsHit[target] = true
1 Like

Is there a way I could use it for hand to hand fighting, would I need a custom character or could I just use the players avatar

1 Like

u cn use their avatar and in u will need to make 2 parts about the size of their hand weld it to their hands and put a bunch of attachments named DmgPoint in the parts u make then once u have welded and put the part in a tool and then parent the tool into the character. i could make smthg like this for u for free if u want i am bored of big maths rn

Can this module be easily exploited by exploiters? Also is there any things to take notes of when using this module so it does not gets easily exploited?

1 Like

if you’re using this module on the server, I dont think it can be exploited

It will be up to the developer to implement sanity checks. This module only takes care of the basic hit detection using raycasting methods. It leaves it open for other developers to do what they need to do without added bloat. You can use this module server-sided which will automatically make it secure, but you leave player experience and responsiveness on the table by doing so.

You can search this thread for my posts regarding sanity checking and security. I left some thoughts for other people in them and it may help you.

1 Like

Hey! I’m running into an issue where the hitbox becomes too inaccurate at <60FPS. Should I try reworking the animation or is there some other solution I can attempt for fixing this? You can see that at 30 FPS, some of the hits in the 5 hit chain miss completely because of the inaccuracy.

Unfortunately, the module relies on framerate to determine positions. Any frames lost in between also means lost locational data. This is designed so it can compensate for lag and increase performance. There is one solution that personally I use myself to counteract this. This may also help you as I have similar animations in my game similar in speed to yours.

I have both this module on the client (to simulate effects and responsiveness) and on the server (to detect actual hit detection). Since the server has a constant replication rate, it does a decent job at detecting hits even if the client is lagging (however still not as accurate as 60 FPS clients). You can also do the Battlefield way where if a client is lagging (under 60 FPS), it switches to server-sided hit detection, and back to client-sided hit detection once they are back to 60.

4 Likes

I ended up doing server-side detection as well before reading your reply, and it’s working out pretty well! Red is client, green is server!

Now that I have the basic functionality in, I think I’ll handle effects the same way you are. I might also take a look at the Battlefield method you mentioned. Thank you!

1 Like

Hello, while I was implementing the combat system in my game I noticed that if you stand still and use the raycast hitbox it most of the times doesn’t hit. Anyone knows how to fix this problem?