Start typing to search packages!
server-hitbox
By @hafpcuh
Roblox
MirroredServerHitbox
a hitbox library fully made from scratch
api explanation, and hitbox config explanation
this library includes:
- hitbox shapes (block, and sphere)
- named hitboxes (optional)
- debug parts (thanks to ObjectCache)
- cast rules
installation
method 1: manually
- download the latest release
- insert the
.rbxmfile into Roblox Studio, and place it anywhere you like (e.g. ReplicatedStorage)
method 2: filesystem
- download the
srcfolder, or clone the repository (usegit clone) - place the
srcfolder anywhere you like, and rename it toServerHitbox, or anything else - use Rojo to sync the files
example usage
local ServerHitbox = -- // path to library
local Hitbox = ServerHitbox.new({
CFrame = CFrame.new(0, 8, 0),
Size = 7
})
Hitbox.Hit:Connect(function(
Hit: Humanoid
)
Hit:TakeDamage(25)
end)
Hitbox:Start()
what are cast rules?
cast rules are functions, that get used upon casting, and checking if they didnt break that rule
here are some examples of what they can do:
--[[
hey, i want to make it, so it only hits parts named "HumanoidRootPart",
for "accurate" hitboxes
]]
Hitbox:AddCastRule("Instance", function(Hit)
return Hit.Name == "HumanoidRootPart"
end)
--[[
hey, i want to make it, so it only can only hit humanoids,
when their health is over 0
(because really, whats the point of damaging the humanoid when its already dead)
]]
Hitbox:AddCastRule("Humanoid", function(Hit)
return Hit.Health > 0
end)
hitbox api
-
ServerHitbox.new(Config: Config) | returns Hitbox
- creates a new hitbox class
-
ServerHitbox:GetActive(Key: string) | returns Hitbox?
- returns the following hitbox (if it even exists in the first place)
-
Hitbox:Start()
- starts the hitbox, if not active
-
Hitbox:Stop()
- ends the hitbox, if active
-
Hitbox:Cast() | returns { (Instance | Humanoid)? }
- casts a bounding area
-
Hitbox:Once()
- creates a single hitbox, and fires .Hit if hit someone/something
-
Hitbox:Attach(Instance: Instance?)
- can either attach following Instance, or detach
-
Hitbox:AddCastRule(For: "Humanoid" | "Instance", Rule: (Hit: Humanoid | Instance) -> ())
- creates a new cast rule
-
Hitbox:RemoveCastRule(For: "Humanoid" | "Instance", Index: number)
- removes the following cast rule
-
Hitbox:CheckCastRule(For: "Humanoid" | "Instance") | returns boolean
- checks for that following rule, and returns a boolean
-
Hitbox:GetCFrame() | returns CFrame
- returns a cframe for hitbox placement
-
Hitbox:Destroy()
- self explanatory
hitbox config explanation
main variables (must add)
- CFrame (CFrame) | self explanatory
- Size (Vector3, or number) | self explanatory
optional variables
-
Key (string) | hitbox name
-
Parameters (OverlapParams) | self explanatory
-
Rate (number) | how often should it cast a hitbox (e.g. 1 = 1 per second, 3 = 3 per second, etc.)
- default is 60
- if rate is set under 0, it will run on every heartbeat frame
-
Shape ("Block", or "Sphere") | self explanatory (hitbox shape)
- default is "Block"
-
DetectionMethod ("Constant", or "Once") | what detection method should it use
- default is "Once"
- Constant | doesn't stop at all
- Once | once hit, it will stop
-
HitMethod ("Humanoid", or "Instance") | what hit method should it use
- default is "Humanoid"
- Humanoid | checks for humanoid
- Instance | checks for literally any instance (part, truss, etc.)
-
DestroyOnStop (boolean) | destroy itself on stopping?
- default is false
Package Details
Install command (Click to copy)
Version
1.0.1
License
MIT
Safe for commercial use
Automated license review — not legal advice.
