Raycast Hitbox 4.01: For all your melee needs!

Does this module work for Classic Swordfighting type Swords?

1 Like

It should. The example place on the post has exactly that.

This is extremely useful. I’ll definitely be implementing this into my combat game!

For one of my games i have a script in serverscriptservice that adds the attribute “CanBlock” to your humanoid, this is what the code looks like

		local Humanoid = Character:FindFirstChild("Humanoid")
		if Humanoid ~= nil then	
			Humanoid:SetAttribute("Blocking", false)	
			Humanoid:SetAttribute("CanParry", false)

For a simple blocking mechanic you could check if blocking is true upon hitting the enemy, that would look something like:

local CheckBlock = enemyhumanoid:GetAttribute("Blocking")

if CheckBlock == true then
     --code here depending on what you want to do when they hit a block

1 Like

Hey there, I’m curious if the raycast hitbox module will get another update, since Roblox recently released some new API, the Shapecasts, from here:

Would be really cool if the raycast hitbox could potentially handle shape casts too


Are you going to change the code for this module with the new release of shapecasts??


I’d appreciate it if anyone can help me with using this module,

1 Like

I’m having issues with this. I’m not sure if I am doing something wrong but if I stand still and hit the same character it stops detecting the hits unless I move prior to hitting it.

local handle = script.Parent
local tool = handle.Parent

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RaycastHitbox = require(ReplicatedStorage.RaycastHitboxV4)

local newHitbox = RaycastHitbox.new(script.Parent)
local Params = RaycastParams.new()

local hitSound = handle:WaitForChild("Hit")
local swingSound = handle:WaitForChild("Swing")

local charDefined = false

	if not charDefined then
		charDefined = true
		Params.FilterDescendantsInstances = {tool.Parent}
		Params.FilterType = Enum.RaycastFilterType.Exclude
		newHitbox.RaycastParams = Params

local deboucne = false
local turnOffAfterThisAmountOfSeconds = .25

	if deboucne == false then
		deboucne = true
		tool.Grip = CFrame.new(Vector3.new(0, 0, -1.25)) * CFrame.Angles(math.rad(180),0,0)
		tool.Grip = CFrame.new(Vector3.new(0, 0, -1.25)) * CFrame.Angles(math.rad(90),0,0)
		deboucne = false

newHitbox.OnHit:Connect(function(hit, humanoid)

robloxapp-20230618-2254499.wmv (1.9 MB)

1 Like

wait so we cant fire events in the hit event?

1 Like

I believe the rays would require a non-zero direction vector. Not moving means the displacement is 0 and that means the direction vector’s magnitude is 0, meaning the direction vector is itself a zero vector.

I think this is what is causing you the issues.

@fembussing @IntentionalChaos

I implemented Shapecasts in this module. I have messaged @TeamSwordphin about my Pull Request. You could, however, get the source directly and use it from here:
GitHub - OptimizedFunction/raycastHitboxRbxl: Requires Roblox Studio and knowledge of its API - Free to use for everybody

Original work is by @TeamSwordphin, I have only implemented support for Shapecasts.

Changes Made:



Hitbox.new() now takes two arguments:

  • object: any?
  • ShapecastMode: ShapecastModeEnum?

ShapecastMode defaults to Line if not provided.



  • Uses the classic Raycast method.
  • Casts a single line.


  • Uses the SphereCast method.
  • Casts a circle.
  • Hitbox.SphereCastRadius is used to set the radius for the SphereCast.


  • Uses the BlockCast method
  • Casts a cuboid.
  • Hitbox.BlockCastSize is used to set the radius for the BlockCast.

New Properties:

Hitbox.SphereCastRadius: number

  • This property defines the radius of the sphere to cast when ShapecastMode is set to Sphere

Hitbox.BlockCastSize: Vector3

  • This property defines the size of the cuboid to cast when ShapecastMode is set to Block

Yo Can I Like Use This For Projectiles?

The FastCastModule in question:

Well, you could. But for projectiles, I would suggest using FastCast. It has a lot more features and is specifically for projectiles.

FastCast is better suited for projectiles, but this one is for melee weapons as the title says “For all your melee needs!”, while FastCast on the other hand, it says this in the title “Making a combat game with ranged weapons?”

I want to make damage depend on the attackers stats. I’m having a problem sending and receiving my own tables. So how could I do this?

Off-Topic but I dont think the creator is gonna update this. I checked his profile and it says “Out of devforum due to life stuff.” But he’s probably gonna be active more, so who knows?
Anyways, I dont use this anymore. I’m currently using a “BoundingBox” method to do this. This module is limited. And yes, I still use “Blacklist” and “Whitelist”. I just get the new ones mixed up.
But this causes some lag now.
I hope someone remakes this module!

How is the module limited ?? I don’t see how really.

What happens if i just repeat HitStart() again without calling HitStop()?
It appears that it just restarts the hit detection but im unsure about what the backend looks like or if this causes a performance issue.

Hi, I’ve been attempting to use this Hitbox module for my games combat system however ive encountered a bug. The first chain of Slashes i do when i Join the game just do not work however the second chain of slashes functions perfectly fine no errors nothing im really confused as to why this is occurring

As for the code:

		Params.FilterDescendantsInstances = {Char}
		Params.FilterType = Enum.RaycastFilterType.Exclude
	local	Hitbox = RaycastHitbox.new(Tool)
		Hitbox.DetectionMode = RaycastHitbox.DetectionMode.Default
		Hitbox.RaycastParams = Params

--different part in the code
	local Hitbox = RaycastHitbox:GetHitbox(Tool)
		if Hitbox then
1 Like