HitboxClass | v1.1B | A Powerful OOP-based Hitbox Module

check if the insatnce youre passing exists or not and wether its nil

I’m also experiencing this issue. When it’s not my region, the hitbox will simply not hit anything (client-sided ones).

The module seems good, however could be updated ^ had to rework some stuff due to region issues

i had an issue where it kept firing HitSomeone Connection even though i’ve stopped the hitbox, im typing this so it can be helpful for other users who could have the same issue.

it might be our timing fault that we call the :Start() function which starts the hitbox while the “RunServiceConnection” is Still running, so it overrides it and makes it impossible to disconnect the hitbox event. for this i made sure that it disconnects the Connection before Opening a new one and that fixed the problem for me

Just make sure you disconnect the connection if it exists right after the Start function

> function Hitbox:Start()
> 	if self.RunServiceConnection and typeof(self.RunServiceConnection) == `RBXScriptConnection` then
> 		self.RunServiceConnection:Disconnect()
> 	end

and that fixes it!

2 Likes

You can’t adjust the VelocityPrediction so i made it adjustable ( added: VelocityPredictionFactor ) <3

Use cases:

  • For example your character is at a “fast” paced movement (50 - 100 velocity), you’ll have to change VelocityPredictionFactor to 5, and that predict the character’s velocity properly.
  • Normal VelocityPredictionFactor would be 6 for more “slow” paced movements of the character
function Hitbox.New(HitboxParams)
	-- Rest of the  Code stuffs here
	-- 
	--
	-- ...
	self.VelocityPredictionFactor = HitboxParams.VelocityPredictionFactor or velocityConstant.Value or 6
	-- Rest of the  Code stuffs here
	-- 
	-- ...
	return self, true
end

function Hitbox:SetPosition(newPos)
	local predFact = self.VelocityPredictionFactor or 6

	if RunService:IsServer() and self.PartWeld and self.VelocityPrediction then
		local velocityVector =  newPosition:VectorToObjectSpace(self.PartWeld.AssemblyLinearVelocity) / predFact
		newPosition = newPosition * CFrame.new(velocityVector)
	end

	self.Position = newPosition

	if self.Part then
		self.Part.CFrame = newPosition
	end
end
1 Like

Does anyone else have a problem with it not detecting characters if they’re jumping?