Raycast Hitbox 4.01: For all your melee needs!

how to make weapon hit multiple times like chainsaw?

IF YOU ARE LOOKING FOR THE SOLUTION OF THAT BUG IN WHICH HITBOX HITS FARTHER THAN IT’S ACTUALLY IS, HERE IT IS:

Put this script inside of Attachment solver module

--!strict
--- Calculates ray origin and directions for attachment-based raycast points
-- @author Swordphin123

local solver = {}

--- Solve direction and length of the ray by comparing current and last frame's positions
-- @param point type
function solver:Solve(point: {[string]: any}): (Vector3, Vector3)
	--- If LastPosition is nil (caused by if the hitbox was stopped previously), rewrite its value to the current point position
	if not point.LastPosition then
		point.LastPosition = point.Instances[1].WorldPosition
	end
	local origin: Vector3 = point.LastPosition
	local direction: Vector3 = point.Instances[1].WorldPosition - point.LastPosition

	return origin, direction
end

function solver:UpdateToNextPosition(point: {[string]: any}): Vector3
	return point.Instances[1].WorldPosition
end

function solver:Visualize(point: {[string]: any}): CFrame
	return CFrame.lookAt(point.Instances[1].WorldPosition, point.LastPosition)
end

return solver
14 Likes

Hi, I am trying to use this for server hit detection, but I can’t seem to figure out how to make it work

My client sided code consists of detecting a player key press, and activating a server event with no parameters

My server sided code is what I am trying to figure out. I receive the event on the server, then I am wondering if I have to make a new hitbox object assigned to a player each time to detect punch hits, but I feel this is a bad way to go about it.

Please help

i fixed it, it was an issue with the method i was using to position the model

just use link attachments
make a for loop to index for link attachments and put it in a module and do index stuff idk
and name the attachments something like 1A, 1B its simpler

I would probably only have the client have the hotbox and make the server perform a series of checks. It works but it’s probably not the best way if you want it super secure

Two things.
One, would this be the most efficient and smooth way?
Two, how would a series of checks look like (what do you mean)
Thanks

It would be efficient and smooth for both the client and the server, but you would need to perform checks to make sure the player isn’t hacking. It would be like sending a remote everytime an action is performed like swinging then if they hit someone it has to be while the server sees them swinging, and also compares positions to make sure they’re actually near the player

1 Like

I see, thank you so much! I will implement immediately

any idea why my hitbox is a million miles away when i set it to my viewmodel’s hitbox.

is the viewmoedl set with position or cframe? and is it client sided or serversided

1 Like

set with cframe, its client sided. could setting its cframe mess it up?

sometimes it randomly fixes itself completely… especially when i sit afk for a while.

how did you set up the attachments since this stuff fixed for me when i swapped to cframe

the attachments are in a mesh in a tool, and the tool is inside the viewmodel.

tool gets equipped by viewmodel every equip. and its a clone of the tool currently equipped (cloned once and cached for reequips, and keeps same hitbox)

image

Is there anyway to destroy connections? if on equip I create a new raycast and have

self.NewHitbox.OnHit:Connect(function(_, humanoid)

then when I unequip I just do

self.NewHitbox = nil

unsure if connection still there, thus constantly equipping/unequipping would create a ton of connections

1 Like

you wouldnt of had to do that since it makes a new hitbox with the same variable so it basically just clears

1 Like

robloxapp-20240116-1741368.wmv (2.9 MB)
i noticed there is a delay between the swing location and hitbox casting
is there anyway to prevent that delay?

3 Likes

Is there any benefit to using this over region3s? I’m trying to create a simple fist combat system and I’m noticing that when I create a single attachment on the hands or legs of the players character, I have to manually go in and set the position of these attachments. When I’m trying to create combat that flows and I have to manually add a dozen attachments to the arms or legs because I can’t change the size of the hitboxes, it feels incredibly tedious, especially given that the animations I’m using change what part of the player’s body is attacking, meaning that I have to change the attachments for each m1 depending on the animation, making this whole process pretty annoying and I seen no reason to use this over region3s which are as simple as creating 1 bound box and then your good to go.

1 Like

Hey’o - I’ve recently made a PR for Raycast Hitbox! PR essentially just adds the raycast-hitbox package to Wally, would be AWESOME if you could give it a review when you’re next avaliable :smile: - no pressure though!

2 Likes