Raycast Hitbox 4.01: For all your melee needs!

So, I was making this Module work with my game and I stumbled upon something weird, in the API it says " RaycastHitModule:GetHitbox" but what is “RaycastHitModule” since when we’re talking about the main module, above it’s referred to “RaycastHitbox” I tried using the function GetHitbox() on the “RaycastHitbox” module but it returns a nil value, even though the hitboxes initialize successfully. Please help.

Its an old function that I forgot to add back in when I revamped the module. The newest version, v2.2 is available on my github that fixes the missing function so you can download it there. I will update it on the actual site soon.

Alright, thank you. I love the module btw, It’s really easy to adapt from old .Touched Hitboxes. :+1:

1 Like

Ok, so I stumbled upon another weird thing, when I initalize the hitboxes that I’m going to use, and call them using the :GetHitbox() function, it creates them again? I only call the initalize function once, and when I execute the attack it warns me that “This hitbox already exists”, even though it’s not initializing it again. I’m using Hitbox:HitStart() and Hitbox:HitEnd() only, so I don’t know what causes this issue. This glitch is very problematic, since it creates the Hitboxes, and they stack over and over dealing progressively more damage upon reaching the point of a one shot kill.

Doesn’t sound like an issue with the hitbox function but are you forgetting to disconnect the OnHit when you are done with HitStop()? You are creating a new thread when you run the connection line but it is difficult to diagnose if you don’t provide sample code.

1 Like

My bad, I didn’t know you had to disconnect it, it worked, thanks.

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