Raycast Hitbox 4.01: For all your melee needs!

how could i make attachments go along the arm with this module? or is there a function for that (i think there is i just can’t find it)

Attachments are objects parented to parts that you can make beforehand (in studio) or with a script. They will always move relative to the part you insert them in. There are no functions in this module to make them for you. A user a while back posted an attachment resolution code that auto generates attachments in a line, which may be of help to you.

1 Like

i know what attachments are, i’m using this for fist combat and i was wondering how to make attachments go along the arm / fist; thanks for the help

This is really useful, thank you for making this hitbox Raycast open-source.

1 Like

Hello again, I’d like to know if this module is compatible with CanCollide false parts or CollisionGroups that dont collide with the default collision group. Thanks.

It behaves as normal raycasting does. It will detect parts regardless if they can interact with physics.This module uses the new Raycast API, and recently Roblox launched a new CollisionGroup property for Raycast Params. You can use that same property here with minimal effort.

Example code:

local RaycastHitbox = require(workspace.RaycastHitboxV2)

local Hitbox = RaycastHitbox:Initialize(Character, {Character})
Hitbox.raycastParams.CollisionGroup = "Default"
1 Like

Thank you, very useful information. Will look into it.

V.2.2 Stable

I’ve decided to de-clog a lot of useless information from the main thread and updated some minor features in the module itself, such as small performance improvements and a new WarningMessage bool that disables/enables most of the spammy messages that appears in the output. This should in theory also improve performance if you leave it off.

On another unrelated note, I’m proud to announce that I’ve updated my github repository with a new wiki! I’ve made sure to keep it clean and simple to navigate!

3 Likes

Heya, I just made a pull request to include a license. I think at this stage of the resource’s development it would be good to include one and it’s typically best for FOSS to come accompanied with one. Thought it’d be a good time now, with the update, to possibly also get that on (or a different license of your choosing).

1 Like

Do you know why my punches are doing large amounts of damage? It should only be about 10 damage per punch.

https://gyazo.com/7c0ae1d9bf081714738cf6294ff31797

local RaycastHitbox = require(game.ReplicatedStorage.Modules.RaycastHitboxV2)
	
	local Hitbox = RaycastHitbox:Initialize(StandModel.RightHand, IgnoreList)
	Hitbox:DebugMode(true)

local MyHitboxConnection
		MyHitboxConnection = Hitbox.OnHit:Connect(function(hit, humanoid)
		humanoid:TakeDamage(10)
	end)
		
	if Enabled == false then return end
	if Action == "Combat" then
	Enabled = false		
	Combo = Combo + 1	
			
		spawn(function()
			local OldCombo = Combo
			Player.Character:WaitForChild("EchoesA3").Combat.Value = true			
			Attachment1.WorldPosition = (Player.Character:WaitForChild("HumanoidRootPart").CFrame * CFrame.new(0,0.25,-3)).p			
			Hitbox:HitStart()		
			wait(Timer)	
			Hitbox:HitStop()		
			MyHitboxConnection:Disconnect()
			if Combo == OldCombo then			
			Attachment1.WorldPosition = (Player.Character:WaitForChild("HumanoidRootPart").CFrame * CFrame.new(2,1,3)).p				
			Combo = 0												
			Enabled = false		
			Player.Character:WaitForChild("EchoesA3").Combat.Value = false						
			wait(2)					
			Enabled = true			
			end	
		end)

Because you aren’t checking if the Damage has already been done to the same Humanoid before, you can find tutorials on how to solve this.

Oh ok, i know how to solve this issue already, i just didnt know what to solve at first. Thanks

How can you get this to work on the players left/right arms?

You can put the attachments in both left / right arms (through StarterCharacter or scripted means) and there are two ways you can go about this.

Method 1 is if you want both arms to be one singular hitbox that activates for both arms. This one is the easiest to implement if you aren’t picky about which arm is active or not.

local Character = Character.Path.Here
local ArmsHitbox = RAYCASTMODULE:Initialize(Character, {Character})

--- When Attacking
ArmsHitbox:HitStart()

--- When Wanting to Stop Attacking
ArmsHitbox:HitStop()

Method 2 is if you want to separate both arms to be their individual hitboxes. This one can be similarly configured.

local Character = Path.To.Character

local LeftArmHitbox = RAYCASTMODULE:Initialize(Character.LeftArm, {Character})
local RightArmHitbox = RAYCASTMODULE:Initialize(Character.RightArm, {Character})

--- Turns on Left Arm Hitbox
LeftArmHitbox:HitStart()

--- Turns on Right Arm Hitbox
RightArmHitbox:HitStart()
3 Likes

can this be used to make a shield hitbox?

How can I put the attachments on the players arms?

1 Like

@epictitanic6g This module does not discriminate hitbox sizes. So yes you can. It is designed to be universal and not simply for swords.

@ErskinePierre I would consider looking up Roblox tutorials or asking around the Building/Support subforum as that is out the scope of this module.

A good starting point on what and how to insert attachments can be found here. This module does not use constraints, but it does use attachments the same way constraints require them.

2 Likes

@TeamSwordphin Hi, I see that the OnHit function has a rayresult thingy but I am looking for the HitPosition of the ray which hit, how would I get it? Im assuming with that rayresult thingy but there isnt much detail about it so idk what to do

It is a RaycastResult parameter. See Documentation:

Hitbox.OnHit:Connect(function(hit, humanoid, raycastResult)
     local hitPosition = raycastResult.Position
     print(hitPosition)
end)
1 Like

@TeamSwordphin How much “DmgPoints” Attachment would be considered a good amount to insert inside a players arm or leg?