Magnitude Hitboxes Module - Create magnitude hitboxes with this module!

PLEASE DON’T USE THIS MAGNITUDE HITBOX MODULE!! I URGE YOU TO USE AN IMPROVED MUCH MORE OPTIMIZED/PERFORMANT MODULE (PLEASE USE THIS MODULE)

I DON’T RECOMMEND YOU TO USE THIS MODULE PLEASE USE THIS MODULE (PLEASE USE THIS MODULE) I’M NOT GOING TO DELETE THIS PAGE BECAUSE I WISH TO ARCHIVE THIS AS IT’S MY FIRST COMMUNITY RESOURCE

Introduction:

What this module do?

  • This module creates magnitude hitboxes with ease.

How to use this module:

  • This module is very easy to use as it uses OOP, allowing you to easily create hitboxes. The only limitation of this module is that it only hits someone once.

Example usage of this module:

--this script will be put inside of a tool.
local hitboxModule = require(path to this module) 
local tool = script.Parent
local newHitbox

tool.Equipped:Connect(function()
	newHitbox = hitboxModule.new(script.Parent.Parent,tool.Handle,3,false) --this would make a hitbox
																				--for our character who will be immune of getting
																				--by their own hitboxes.
																				--The hitbox part is our character's tool handle.
																				--the range of this hitbox is 3 magnitudes.
																				--And it would not be automatically destroy or clean up
																				--once you do newHitbox:StartHitbox(...)
																				
	newHitbox.Hit:Connect(function(enemyCharacter) --this function will fire once someone gets hit by the hitbox
		enemyCharacter.Humanoid:TakeDamage(5)		--and they will take 5 damage
	end)
end)

tool.Unequipped:Connect(function()
   newHitbox:StopHitbox() -- this stops any hitboxes that started for this tool
   newHitbox:Destroy() -- this will destroy the hitbox and disconnect all signals therefore cleaning things up
end)

tool.Activated:Connect(function()
    newHitbox:StartHitbox(3) -- the hitbox will last for 3 seconds.
end)

There’s of course a better way to use this.

The API for this module can be found inside of the module itself.

Again this is my first community resource, any feedback and criticism would be super helpful to improving this module and this post in general.

8 Likes

Very good for your first! I’m sure this will help many. Keep it up!

3 Likes

Forgot to mention that if you want to turn off the hitbox visuals you’ll need to go into the hitbox module script and change the visual variable to false

local visuals = false--set this to true if you want to visualize the hitboxes

this will turn off all the hitbox visuals

Why are you looping it if it’s already an event? Isn’t that bad practice?

This is indeed bad practice I’ll edit the script.

I’ve made changes to the example and the example place (as well the module itself). I apologies for any inconvenience.

same question as for every other person making hitbox modules. Have you done benchmarking?

What do you mean by benchmarking? May you please elaborate?

Sure! It’s often used to test a computer’s specs. (I think it’s also about market charts too)
Basically they are charts showing performance / profit / costs / prices, etc.
But in this case, i think just adding a startTime = time() <<CODE>> print(startime-time()) as a test would be enough (Using your MOST performance expensive + cheap method)
→ Note that im talking about the time it took to run it which might not sound too exact. But it does check how time it took to load so it’s fine! (which is at least what im looking for)

Now when it comes to different devices… I would recommend running a local server with the 2MGs roblox’s servers have, as literally any window for script performance is absurdly complex or depends on your computer.

This might take a while but, you know those “Why this over that” ? That’d totally convince people if you had lower numbers.

Or in a few words. Numbers - Data - Info about performance

1 Like

Sorry if this seems dumb, but where do I put the small piece of the code? Do I put it in the module itself? or a normal script? I put this piece of code in the module and the basic example and got 0 from the output.

Set start time before you run the Hitbox check. Then after the check.
About where: you place it as if someone was making a script using your module (not the API but some script outside, you can also do some benchmarking inside your API to check which part of the code slows it down)

I gotta say I’m not experienced in this at all so I might get many things wrong! Maybe you can find some posts about this. What I’m looking for is how much it takes for the Hitbox to run the checks n such.

So if you still get 0 then I guess that’s good? Try putting many many parts inside and give it a heavy task. make it have a hard time. Whatever makes it slow

Yeah it seems like it’s still 0

1 Like

Well, I told you I only know the concept and what it’s used for but not exactly do it myself. I plan on doing some benchmarking on many hitbox modules. So I’ll @ you when I get some results

use os.clock as your time might be zero but with some decimals. and also for more accurate result

2 Likes

image
These are some of the times to connect for one hitbox. (to do something with the person who got hit)

image
these are some of the times to connect for 200 different hitboxes. (to do something with the person who got hit)

1 Like

image

hitbox only works the first time

no errors at all, no clue why this happens

This should clarify why.

30char

I’m currently remaking the hitbox module (it may also contain the same limitations or even more in exchange for being optimization) I’ll mark the new hitbox module as solution when I’m done.

PLEASE DON’T USE THIS MAGNITUDE HITBOX MODULE!! I URGE YOU TO USE AN IMPROVED MUCH MORE OPTIMIZED/PERFORMANT MODULE (PLEASE USE THIS MODULE)