Hitbox Expander
Let’s face the truth: most Roblox FPS players suck with their aim. Solution? Make it take less effort to aim.
I often see newer FPS developers have trouble with creating custom hitboxes to solve this problem. To help out, I’ve created a custom hitbox system that will be super easy to implement with your existing raycast system!
First, download the system
Download the below file and import it into the game you choose.
HitboxPackage.rbxm (4.2 KB)
Next, unpack the system
-
HitboxLoader
belongs in ServerScriptService -
HitboxLoaderClient
belongs in either ReplicatedFirst or StarterPlayerScripts -
HitboxHandler
belongs in ReplicatedStorage
After unpacking everything, delete the package parent.
What happens by default?
At this point, your hitboxes will be automatically created. While you cannot see them, they are there!
By now, it’s up to you to integrate the hitbox system into your existing raycasting code.
You can also change the hitbox size by editing the HITBOX_ADD_SIZE
constant in HitboxHandler.Hitbox
.
Integrating the hitbox system
HitboxHandler
has a method that is helpful for developers to raycast!
Call HitboxHandler:RaycastForHitbox(...)
. The parameters should be exactly the same as if you were to do workspace:Raycast(...)
.
However, it does not return just a RaycastResult
instance. Instead, it will return four values! Below is an example:
local HitCharacter, HitInstance, HitPosition, RaycastResult = HitboxHandler:RaycastForHitbox(...)
HitCharacter
is the detected character that was hit. nil
if none.
HitInstance
is the hit instance, such as a part of player limb. nil
if none.
HitPosition
is a the position of the raycast result. nil
if none.
RaycastResult
is the raw result for the raycast. This means if you read RaycastResult.Instance
, you will get the hitbox part, not the player limb. nil
if no raycast result.
That’s it!
Hopefully this works well enough for new developers. Feel free to modify for your own use.
Check out an example of a game using this system! Click here.