MaxHitbox
This is my first ever hitbox system that I believe could come in handy in terms of Fighting Games, Weapons, etc. This module may have a feature that you’ve been waiting for a while. Nonetheless, let’s get into the features of this module.
You can download the module here:
MaxHitbox - Creator Store
So first let’s set up an example hitbox:
local MaxHitbox = require(path.to.module)
local newHitbox = {
Mode = "Default", -- There are three modes: Default, ConstantDetection, DestroyOnHit,
Shape = "Box", -- You can change the shape of the hitbox. Options are: Sphere, Box
TouchMode = "Humanoid", -- There are three touch modes: Humanoid, Object and Both
Size = Vector3.new(0,0,0) or number, -- This will be the size of the hitbox, Vector3 if the Shape is a Box, a number if the Shape is Sphere
CFrame = CFrame.new(0,0,0), -- This is the position (CFrame) of the hitbox,
Debris = 3, -- The time the hitbox has before being destroyed
Blacklist = {}, -- Items in the table will be ignored by the hitbox
Visualizer = false, -- This either enables or disables a hitbox visualizer
}
newHitbox:Start()
Then you want to make a function where the hitbox touches something:
Humanoid
newHitbox.HumanoidTouched:Connect(function(character, humanoid)
----Character represents the model with a humanoid
----Humanoid represents the Character's Humanoid
end)
Object
newHitbox.Touched:Connect(function(object)
---object is the Object that's touched
end)
Both
newHitbox.HumanoidTouched:Connect(function(character, humanoid)
----Character represents the model with a humanoid
----Humanoid represents the Character's Humanoid
end)
newHitbox.Touched:Connect(function(obj)
---object is the Object that's touched
end)
This example shows how to set up a basic hitbox using this module. Whether it’s object or humanoid detection, or both, it can be done.
Now we are going to go in-depth on how the three modes of the hitbox module. As said before, the three modes are: Default, ConstantDetection, DestroyOnHit.
Default
- This mode will hit the object or humanoid once until the hitbox is destroyed. This can be used for punches or sword slashes
ConstantDetection
- This mode constantly detects an object or humanoid. Also is can be used with
DebounceTime
to delay the hits every amount of that time.
DestroyOnHit
- This mode will make the hitbox disappear when it’s touched. It’s as simplr as that
All of these modes can be used for different purposes. These can even be used for projectiles using the newHitbox:WeldTo()
.
This is the other documentation of the module:
newHitbox:Start(HitParams : {})
- This starts the hitbox with the table of information given inside of the parameter table.
newHitbox:WeldTo(Part : Part, CFrame : CFrame)
- This function allows you to weld a hitbox to a part’s CFrame. You don’t have to include the CFrame parameter if you don’t want an offset of the weld CFrame.
newHitbox:Stop()
- This function destroys the hitbox and its connections, including the visualization.
That’s all for now! It is a bit barebones, since I rushed this. Enjoy the module!! Demonstrations will come out a bit later!