Explosion Based Hitboxes

I have created an explosion, but now i need a hitbox. Obvoiusly, i could go w a simple .touched but we all konw how slow the detection is and I dont want a laggy system,I could also use .magnitude but I want the best way to create a hitbox on the explosion thanks.

Possible approaches I could try:

  • I used touched event many times for different scenarios and works acceptable.
  • Check parts in part, which works with Touch interest too
  • Yup a magnitude loop
  • Region3 check
  • Raycasting check

Magnitude could work…
Maybe try GetPartsInPart with a loop?

local hit = {}

local function e(p)
for i, v in pairs(hit) do
if p.Parent.Name ~= v then
table.insert(hit, p.Parent.Name)
--Damage stuff
end
end
end

while task.wait(0.1) do
for i, v in pairs(workspace:GetPartsInPart(script.Parent, OVERLAPPARAMS_HERE)) do
e(v)
end
end

If you are using Explosion, you can use the Explosion.Hit event.

Could u explain a bit on how to makea magnitude loop, region 3 with a ball shape, and raycasting check. Thanks

its a vfx explosion, so that doesnt work :frowning:

magnitude seems solid but its not extremely effecient as the explosion takes a second and i want to make it so if their even touched they get damged instantly not at a certain time when i check w magnitude if that make sense

Yup region3 wont work with a ball shape. So forget the region3 :stuck_out_tongue:

Yup magnitude could work.
Exactly what u mean with this?

Like the explosion grows during a second, and you dont want to deal the damage after or before the actual “damage sphere” collides with the player?

That could be taken in count, if the magnitude loop reads over time the grow distance of the sphere too, sounds kinda tricky tho…

I could go back and try the Touch event, is not that bad :v

You could add a wait() before the damage script.

task.wait(0.5)

local hit = {}

local function e(p)
for i, v in pairs(hit) do
if p.Parent.Name ~= v then
table.insert(hit, p.Parent.Name)
--Damage stuff
end
end
end

while task.wait(0.1) do
for i, v in pairs(workspace:GetPartsInPart(script.Parent, OVERLAPPARAMS_HERE)) do
e(v)
end
end

I just decided to use magnitude and it worked well tbh thank you.