Making A HitBox

How can I make a hitbox that works but with low lag?

I was making a hitbox system using Spatial Query, and it worked, but it has to use a while loop to run, and I’m certain that would do terrible things to a game if multiple people were playing, is there another way I could make a hitbox w/o running a while loop ?

3 Likes

Why would that need a while loop? Personally this would be a kind of basic hitbox system I would make:

Hitbox = Instance.new("Part", game:GetService("Workspace").Terrain)
Hitbox.CanCollide = false
Hitbox.Anchored = true
Hitbox.Name = "Hitbox"
Hitbox.Size = Vector3.new(5, 6, 6)
Hitbox.CFrame = hrp.CFrame + hrp.CFrame.LookVector * 4

local ReturnedPartsTable = game:GetService("Workspace"):GetPartsInPart(Hitbox, OverlapParams.new())
Hitbox:Destroy()

And then you could simply loop through the ReturnedPartsTable to see if it has anything you want to react with the hitbox.

3 Likes

If you’re looking for a hitbox system that can be used in melee weapons, I would highly recommend that you look into the Raycast Hitbox 4.01 module. It’s widely used in many popular and large games due to it’s reliability and versatility due to using ray casts over physical parts and keeping server load minimal - whilst being easy to implement and adapt into any kind of melee.

1 Like

Thank you this worked, it seems like I was overcomplicating it

1 Like

This looks really useful, thanks for suggesting this, I will look into using it in the future :+1:

1 Like

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