Hi, I am currently working on an attack for a character which involves pausing a running animation. However, my only problem is that the animation won’t pause itself on time to stop the animation from completing. This stops the attack hitbox from appearing.
This appears to be a fairly inconsistent issue however it is consistent enough to be a problem. My current issue is that I cannot figure out why it cannot pause. I already have set the playback speed to 0 at the marker and I have also tried setting the TimePosition of the animation, however none of these are a consistent solution to the problem.
-- hitboxLoop
local hitboxLoop = coroutine.create(function()
local dmgTable = {}
hitboxConnection = game:GetService("RunService").Heartbeat:Connect(function()
for _, offset in pairs(offsetTable) do
local ray = dashRay(offset)
if ray then
local inst = ray.Instance
local hitParent = inst.Parent
if inst:IsA("WedgePart") or inst:IsA("CornerWedgePart") then
return nil
end
beginCharge:Disconnect()
longPunchChargeAnimLoaded:AdjustSpeed(1)
longPunchChargeAnimLoaded:Stop()
if root:FindFirstChild("punchVel") then
root["punchVel"]:Destroy()
end
if hitParent and not dmgTable[hitParent] then
dmgTable[hitParent] = true
local hitHum = hitParent:FindFirstChildWhichIsA("Humanoid")
if hitHum and hitHum.Health > 0 then
hitSomething = true
damageEvent:FireServer(hitHum, dmg.Value * 4, chr)
statusEvent:FireServer(hitHum, "stun", 2.5)
knockbackEvent:FireServer(hitHum, 150, 14)
end
end
end
end
end)
end)
-- Marker Event
local beginCharge
beginCharge = longPunchChargeAnimLoaded:GetMarkerReachedSignal("startAttack"):Connect(function()
beginCharge:Disconnect()
longPunchChargeAnimLoaded:AdjustSpeed(0)
coroutine.resume(hitboxLoop)
for _,pe in pairs(thrusterParticles:GetChildren()) do
if pe:IsA("ParticleEmitter") then
pe.Enabled = true
end
end
local bv = Instance.new("BodyVelocity")
bv.Name = "punchVel"
bv.MaxForce = Vector3.new(1,0,1) * 39999
bv.Velocity = root.CFrame.LookVector * 100
bv.Parent = root
--for count = 1,5 do
-- bv.Velocity *= 0.6
-- task.wait(0.1)
--end
task.wait(0.4)
bv:Destroy()
longPunchChargeAnimLoaded:AdjustSpeed(1)
longPunchChargeAnimLoaded:Stop()
end)
longPunchChargeAnimLoaded.Stopped:Connect(function()
coroutine.close(hitboxLoop)
for _,pe in pairs(thrusterParticles:GetChildren()) do
if pe:IsA("ParticleEmitter") then
pe.Enabled = false
end
end
hitboxConnection:Disconnect()
longPunchHitAnimLoaded:Play()
end)