Im using Muchacho hitbox, And i’ve been wondering which way is more performant, and better.
So at the top of the script, I create the hitbox. (using local hitbox = Muchachohitbox:CreateHitbox())
And when you attack, it enables the hitbox, and then disables it a bit afterwards.
However, i encountered an issue, When you attack once, the damage will be normal, when you attack again, the damage will be doubled, Since the detection for when a player touches the hitbox is in the same place as enabling it
like this:
local hitbox = muchacho_hitbox:CreateHitbox()
---when activated
hitbox:Start()
hitbox.Touched:Connect(function(hit,hum)
hum:TakeDamage(10)
end)
task.wait(1)
hitbox:Stop()
Since im never disconnecting the touched event, It stacks. So i’ve tried this:
local hitbox = muchacho_hitbox:CreateHitbox()
hitbox.Touched:Connect(function(hit,hum)
hum:TakeDamage(10)
end)
---when activated
hitbox:Start()
task.wait(1)
hitbox:Stop()
I can make so the hitbox effects are different by using a variable to determine what attack is the player doing, but i already have alot of tools in my game, and i kind of just want it to be simple.
It works, but not all attacks do the same damage/effects (ex: when activating, a random attack is selected, and you do that attack, but some have different effects, like applying fire to the hit humanoid)
So then i was thinking of this:
local hitbox = muchacho_hitbox:CreateHitbox()
---when activated
hitbox:Start()
local connection = hitbox.Touched:Connect(function(hit,hum)
hum:TakeDamage(10)
end)
task.wait(1)
connection:Disconnect()
hitbox:Stop()
Would this way be fine? or would it be bad since its possible that if a player leaves, then the tool is destroyed before the connection is disconnected (i know this is a stupid question, but im new to how memory works and such, and just want my game to work as performant as possible)
also one other question. for anyone who knows about muchacho hitbox, how do i make so you can hit the same person more than once? i have a tool that has a constantly active hitbox, and cant manage to figure it out.