How can I use RayCastHitboxV4 for a combat system?

Hi DevForum,

I recently learned about RaycastHitboxV4 and was interested in using it in my combat system to detect the players hit by the M1, how can I do so? Thanks again!

1 Like

What’s an ‘M1’? Is that a melee weapon, or a gun?

It’s a fist combat system, that’s why it’s slightly confusing to use the module for me

1 Like

Do you already have a way to add attachments into the fists of the players?

I can, yes, sorry for late reply.

1 Like

Try this out:

If this doesn’t work, double-check the code by looking into the wiki.

local RS = game:GetService("ReplicatedStorage")
local PS = game:GetService("Players")
local RH = require(RS.RaycastHitboxV4)

local tool = script.Parent
local char = if tool:IsDescendantOf(workspace) then tool.Parent else tool.Parent.Parent
--@ guessing that the attachments are already inside the character model
local hitbox = RH.new(char)

tool.Activated:Connect(function()
	--@ starts the raycasting
	hitbox:HitStart()
end)
hitbox.OnHit:Connect(function(hit, hum: Humanoid)
	hum:TakeDamage(30)
end)