{"id":"hafpcuh/server-hitbox","name":"server-hitbox","scope":"hafpcuh","platform":"roblox","description":"Hitbox module. Wow.","version":"1.0.1","latest":"1.0.1","versions":["1.0.0","1.0.1"],"license":"MIT","licenseRating":"safe","licenseCaveats":[],"licenseVerified":true,"dependencies":{},"integrity":"8f00b52effd9b0fda10b663f1af3617abf0671aa15ef401e56bd84a1a07612ef","likes":0,"downloads":0,"install":"forest install hafpcuh/server-hitbox","url":"https://forest.dev/p/roblox/hafpcuh/server-hitbox","files":"https://api.forest.dev/ai/package/roblox/hafpcuh/server-hitbox/files","readme":"# ServerHitbox\r\na hitbox library fully made from scratch<br>\r\n**[api explanation](https://github.com/hafpcuh/ServerHitbox?tab=readme-ov-file#hitbox-api)**, and **[hitbox config explanation](https://github.com/hafpcuh/ServerHitbox?tab=readme-ov-file#hitbox-config-explanation)**\r\n\r\n### this library includes:\r\n- hitbox shapes (block, and sphere)\r\n- named hitboxes (optional)\r\n- debug parts (thanks to ObjectCache)\r\n- [cast rules](https://github.com/hafpcuh/ServerHitbox?tab=readme-ov-file#what-are-cast-rules)\r\n\r\n## installation\r\n\r\n### method 1: manually\r\n* download the [latest release](https://github.com/hafpcuh/ServerHitbox/releases)\r\n* insert the `.rbxm` file into **Roblox Studio**, and place it anywhere you like (e.g. ReplicatedStorage)\r\n\r\n### method 2: filesystem\r\n* download the `src` folder, or clone the repository (use `git clone`)\r\n* place the `src` folder anywhere you like, and rename it to `ServerHitbox`, or anything else\r\n* use [Rojo](https://github.com/rojo-rbx/rojo) to sync the files\r\n\r\n## example usage\r\n```lua\r\nlocal ServerHitbox = -- // path to library\r\n\r\nlocal Hitbox = ServerHitbox.new({\r\n    CFrame = CFrame.new(0, 8, 0),\r\n    Size = 7\r\n})\r\n\r\nHitbox.Hit:Connect(function(\r\n    Hit: Humanoid\r\n)\r\n    Hit:TakeDamage(25)\r\nend)\r\n\r\nHitbox:Start()\r\n```\r\n\r\n## what are cast rules?\r\n**cast rules are functions, that get used upon casting, and checking if they didnt break that rule**<br>\r\nhere are some examples of what they can do:\r\n```lua\r\n--[[\r\n    hey, i want to make it, so it only hits parts named \"HumanoidRootPart\",\r\n    for \"accurate\" hitboxes\r\n]]\r\n\r\nHitbox:AddCastRule(\"Instance\", function(Hit)\r\n    return Hit.Name == \"HumanoidRootPart\"\r\nend)\r\n```\r\n\r\n```lua\r\n--[[\r\n    hey, i want to make it, so it only can only hit humanoids,\r\n    when their health is over 0\r\n\r\n    (because really, whats the point of damaging the humanoid when its already dead)\r\n]]\r\n\r\nHitbox:AddCastRule(\"Humanoid\", function(Hit)\r\n    return Hit.Health > 0\r\nend)\r\n```\r\n\r\n## hitbox api\r\n* ServerHitbox.new(Config: Config) | returns Hitbox\r\n    - creates a new hitbox class\r\n\r\n* ServerHitbox:GetActive(Key: string) | returns Hitbox?\r\n    - returns the following hitbox (if it even exists in the first place)\r\n\r\n* Hitbox:Start()\r\n    - starts the hitbox, if not active\r\n* Hitbox:Stop()\r\n    - ends the hitbox, if active\r\n* Hitbox:Cast() | returns { (Instance | Humanoid)? }\r\n    - casts a bounding area\r\n* Hitbox:Once()\r\n    - creates a single hitbox, and fires .Hit if hit someone/something\r\n\r\n* Hitbox:Attach(Instance: Instance?)\r\n    - can either attach following Instance, or detach\r\n\r\n* Hitbox:AddCastRule(For: \"Humanoid\" | \"Instance\", Rule: (Hit: Humanoid | Instance) -> ())\r\n    - creates a new cast rule\r\n* Hitbox:RemoveCastRule(For: \"Humanoid\" | \"Instance\", Index: number)\r\n    - removes the following cast rule\r\n* Hitbox:CheckCastRule(For: \"Humanoid\" | \"Instance\") | returns boolean\r\n    - checks for that following rule, and returns a boolean\r\n\r\n* Hitbox:GetCFrame() | returns CFrame\r\n    - returns a cframe for hitbox placement\r\n\r\n* Hitbox:Destroy()\r\n    - self explanatory\r\n\r\n## hitbox config explanation\r\n\r\n### main variables (must add)\r\n- CFrame **(CFrame)** |  self explanatory\r\n- Size **(Vector3, or number)** | self explanatory\r\n\r\n### optional variables\r\n- Key **(string)** | hitbox name\r\n\r\n- Parameters **(OverlapParams)** | self explanatory\r\n- Rate **(number)** | how often should it cast a hitbox <sub>*(e.g. 1 = 1 per second, 3 = 3 per second, etc.)*<sub/>\r\n    * **default is 60**\r\n    * if rate is set under 0, it will run on every heartbeat frame\r\n\r\n- Shape **(\"Block\", or \"Sphere\")** | self explanatory (hitbox shape)\r\n    * **default is \"Block\"**\r\n- DetectionMethod **(\"Constant\", or \"Once\")** | what detection method should it use\r\n    * **default is \"Once\"**\r\n    * Constant | doesn't stop at all\r\n    * Once | once hit, it will stop\r\n- HitMethod **(\"Humanoid\", or \"Instance\")** | what hit method should it use\r\n    * **default is \"Humanoid\"**\r\n    * Humanoid | checks for humanoid\r\n    * Instance | checks for literally any instance (part, truss, etc.)\r\n\r\n- DestroyOnStop **(boolean)** | destroy itself on stopping?\r\n    * **default is false**","readmeTruncated":false}