so today i made this fireaxe melee for one of my side projects, it was working fine until i noticed that throughout every use of it, the hitbox duration and the debounce duration increased more and more to the point it lasted almost forever, if anyone knows why this happens and could give me a possible fix, i would highly appreciate it
Code (ServerSided because i dont trust the client)
Tool.Activated:Connect(function()
if CanAttack == true and DB == false then
DB = true
AttackAnim:Play()
if AnimatedWM:FindFirstChild("Trail") then
AnimatedWM:WaitForChild("Swing"):Play()
AnimatedWM:WaitForChild("Trail", 1).Enabled = true
else
end
local Damage = coroutine.wrap(function()
RUNSERVICE.Heartbeat:Connect(function()
wait()
for i,Model in pairs(game.Workspace:GetChildren()) do
if Model:IsA("Model") and Model:FindFirstChild("HumanoidRootPart") and DB == true and Model ~= Character and Swinged == false then
if (AnimatedWM.Position - Model.HumanoidRootPart.Position).Magnitude <= 4.4 then
local SoundsTable = {}
for _, v in pairs(AnimatedWM:WaitForChild("Sounds"):GetChildren()) do
table.insert(SoundsTable, v)
end
local RandomSound = SoundsTable[math.random(1, #SoundsTable)]
RandomSound:Play()
Swinged = true
Model:WaitForChild("Humanoid"):TakeDamage(18)
else
end
else
end
end
end)
end)
wait(0.4)
Damage()
wait(0.3)
if AnimatedWM:FindFirstChild("Trail") then
AnimatedWM:WaitForChild("Trail", 1).Enabled = false
else
end
Swinged = true
wait(1.4)
Swinged = false
DB = false
end
end)