Better way of handling hitboxes?

So… Ive been inspired by fighting games like item asylum and tried replicating the hitbox system…
From my understanding it creates x amount of hitboxes then stops when it hits someone
now im barely an intermediate scripter and already made some sort of system but… yeah its not that good/optimized I think is there any way to salvage this? Or should I just try some other method?
VV Rblx place I added comments to help show what each thing does kinda VV
HitboxTestThatSucks.rbxl (97.5 KB)

3 Likes

Where did you find that item asylum uses that kind of hitbox system?

Via the hitbox debug it generates multiple boxes until it hits something

I do something kind of like IA except it’s a single hitbox, attached to the character, that lasts x seconds and then disappears. It can hit multiple enemies and apply knockback if necessary, which is cool.

1 Like

hmm I see, how do you handle collisions? Like do you use renderstepped or something?

close, I use heartbeat on server script.

local HB
local function hit(Part)
--function stuff
end
HB = game:GetService("RunService").Heartbeat:Connect(function()
for i, Part in pairs(workspace:GetPartsInPart(Hitbox) do
hit(Part)
end)
task.wait(ATKtime)
HB:Disconnect()

demo code at 3 AM lol
btw, I only did this because my version of multiple hitboxes was delayed

1 Like

sushimanster does a good job of making the hitbox u could try use the way how he handles the hitbox in the module

Hey! so I tried ur script and I just have 1 question
do you destroy the hitbox after it hits someone or only after the timers done? Just asking how I should be handling this since im kinda rusty at scripting

Oh yeah.
So it’s a multi-hitting hitbox that gets destroyed after the timer is over.

local List = {} --Everybody who got hit before so no double hitting
local HB
local function hit(Part)
if Part.Parent:FindFirstChild("Humanoid") and not table.find(List,Part.Parent) then --If you haven't hit the character and it has a humanoid
table.insert(List,Part.Parent) --Basically debounce but just for one player
--[[
task.wait(0.5) --If you want a character to be hit multiple times by the same hitbox, remove the --[[]] thing
table.remove(List,List[Part.Parent]) --Debounce is false, character can be hit again
]]
end
--function stuff
end
local Hitbox = instance.new("Part",Character)
Hitbox.Parent = workspace
--Customize and Motor6D it to the character
HB = game:GetService("RunService").Heartbeat:Connect(function()
for i, Part in pairs(workspace:GetPartsInPart(Hitbox) do
hit(Part)
end)
task.wait(ATKtime)
HB:Disconnect()
Hitbox:Destroy()

You should use Debris + Magnitude check. This should get you the intended result.
Sorry for necro-posting.

What I did was make a part in serverstorage called hit box. When the player M1s it sends a remote event to a server script which clones the parts, uses GetPartsInPart() and then checks if it’s a humanoid, if it is, then it damages it.

Depends on what type of gameplay you want. If you want something fast paced, you can just use a Part and get Overlapping parts. If you want something slower paced, use raycasting.

1 Like