I use a lot of parts for hitbox, how can I make a hitbox without using parts?


The more pixels you have in your game, the more lag you will have unfortunately so the best solution is to find ways to use less pixels

1 Like

But this time the sword cuts 4 pixels with one touch, not 1 pixel. This is not the game I want.
The game I’m trying to make is “clone drone in the danger zone”
As I said, I’m thinking of changing my game a little or just playing with my friends.

I looked up “clone drone in the danger zone” in Google and found that is uses Unity as a game engine. I never used it before but it probably has ways to optimize what you’re trying to do that I don’t think is currently possible in Roblox at the moment but I could be wrong. I wish you luck in making this though :slightly_smiling_face:

Thank you for trying to help___

1 Like

Alright, let’s get back to the topic with almost a fresh start ! But please do note this may not be very accurate!


We are trying to optamize the game by not having too many "Base Parts" but why don't we also reduce the amount of "hitboxes"?

Yes, you heard me right, and I am well aware I am repeating what @JohhnyLegoKing said but trust me this is worth a short ! But What do I mean my reducing hitbox and baseParts? Just remove most parts and replace them with one big chunk duh! what else do you think ?

If I reduce the hitbox, the sword will cut that amout of pixels tho ?!

But before I explain have a look at this image which might help you understand about what I am going to say.

In the image below, there are alot of hitboxes and baseParts before and after damage on the current version (which is your current version) but as for the Possible version, we only got 1 basePart and 1 Hitbox before damage and 2 BasePart and 2 hitboxes after damage. What a reveloution! (I am just trying to amuse my self don’t take it the wrong way :sweat_smile:) Oh and the damage was taken on the bottom right corner.

We are first going to reduce the amount of parts as possible. Then when we want to remove the part we damaged, we are going to remove the part where the hitbox was activated (because the part is inside of the hitbox). Finally place hitboxes (Oops I just realized we might not want to add hitbox, oh wait its ok to add it through server duh! oof Got worried for a sec!) or / and baseParts to fill the chunk we removed accordingly (“accordingly” because we don’t want to fill the damaged chunk).

Simple as that!

But wait, How would I script that? (That seems complexed !)

if it does seem complexed then you are right, for some of us it is :sweat_smile: ! I mean when I thought of this idea 8 hours ago I was like « man that would take me hours to code a system that complexed… »
But it’s coding, It suppose to be like that. That’s why I love coding so much.

Let’s get to the point

For this to work, We might want to use rayCast.

Why rayCast you ask? Simply because this will help us determine where to generate / render small parts considering the Distance and help us see what to do next. (THE DISTANCE, PLEASE PLEASE tell me if I am wrong, I am actually having a headache writing about raycast as I only used it once. And man this is long.)

This is how it works: Use ray cast 3 times when you use your tool ! On the vector of when the touch begins and the touch ends as well as the middle of these 2 touches. Let’s say when we used our tool we first hit the hitbox at Vector3.new(10, 10, 10) and we finish the hit at Vector3.new(15,15,15). Now we determine the middle of these 2 vectors which would be Vector3.new(12.5, 12.5, 12.5). Now once you have all these vectors, Lets try to divide the part(s) into small chunks. So if a part was Vector3.new(10,10,10) in size, we divide it by .25 to get the total amount of small parts we can place inside that big part. Now you’ll have to loop through these parts in that “chunk” and calculate the position of these small parts and see if they should be removed or not. Calculate the parts to remove and determine the amount of parts to remove and place to new area (size and position) then reove the part(s inside) the hitbox(es) and replace them with the new parts you got !

the Nearest parts to the player in this picture are the parts you want to remove !

And you have your system with less lag!

You got your unique way of writing your code ! So it’s up to you to decide how you are going to make it work! So have fun! That was truly long and man I am never going to talk about raycasting ever untill I get to know about it more…

Only ask for a sample code If you are really struggling !

3 Likes

Yes, thank you very much for making a very good presentation, but you could not help me fully because I did not explain my problem in detail, I’m sorry
but I came up with a good idea and I think it will work so I’ll mark it as solved!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.