What is your best way to create a hitbox?

Well, as we all know, Roblox’s hitbox isn’t a great way to make hitboxes. So I’m making this thread to ask you what’s the best way to make hitboxes.

How would you format your own post from this thread?

  • Firstly, I wanna know what is the way of making the hitbox
  • Secondly, What is it’s pros and cons?
  • Thirdly, How useful is it? (Like for ranged weapon or melee ones)
  • How would you perform it on roblox (No need an actual code, I just need an example)
  • How performance is it
  • Addiontal notes or tips.

For example:

As you all know, Roblox’s built in function Touched event. It is very good for beginner to use.

Pros:

  • Easy to use
  • Work well
    Cons:
  • Isn’t funny with unions
  • It’s TouchEnded is way too bad
-- Example code:
local part = Instance.new("Part")

part.Touched:Connect(function(hit) -- the part that hit
    hit.Color = Color3.fromRBG(255,0,0)
end)

Well I think it is good to use as a beginner to Roblox, but I think it will cause serious problem if you keep spamming thousand of .Touched events.

Notes: Making guns with bullet's .Touched event isn’t good and is very bad.

P/S: I wanted to make this post on #discussion but it is locked so yeah I have to post it there.

11 Likes

Alright so, I’m a beginner to Roblox scripting as well, so I don’t know much about this. But I do know a handful of resources you could have use to.

DevForum Topics:

  • Take a look at this topic, titled “Best Way to Make Hitboxes”. I think that this topic will answer most of your questions.

  • Check out this topic - it goes over all the steps of making good hitboxes, and will teach you some of the fundamentals of a hitbox.

  • There’s actually a topic in the #resources category, created by @TeamSwordphin, that provides you with a useful Raycast Hitbox Module and steps on how to use it.

  • Let’s say you’re having a trouble with a hitbox. This topic should help out with that. I recommend you take a look at it because many properties of hitboxes will be discussed within the topic.

  • This topic goes over merging melees and hitboxes - you might learn a thing or two!

  • If you want to learn more about hitbox detection, then this topic is the way to go.

  • There’s also some additional information regarding hitbox scripting in this topic.

Developer Hub Articles:

  • While surfing through the topics above, I’m sure that Region3 will be mentioned quite a bit. If you don’t know what that is, read this article from the Developer Hub.

  • The term Raycasting will be popular as well. See this article for an intro to Raycasting.

YouTube videos:

  • From what I know about hitboxes so far, Magnitude would be another relevant property. See this video for a quick overview on that.

Quick reminder:

As you can see, there are so many topics that were made on hitboxes, so just a friendly reminder to search your question before making the same topic again. It just helps reduce spam on the Forum.

And that’s it!

Hope you found each of my resources useful and able to answer some of your questions!

25 Likes

have you tried raycasting?
Raycasting | Documentation - Roblox Creator Hub.

Well thanks. (30 characterssss)

1 Like