Currently, I’m trying to get my firing animation for my gun to work, and it does but, when the mouse1 input ends, the animation is stopped immediately when I actually want it to finish playing out before stopping.
I thought I could go about doing this by adding an animation event to the end of the animation and waiting until the marker is reached and then stopping the animation there.
Problem is, I’ve no idea what I should be doing to implement this and my attempt so far hasn’t worked out.
Local script
local function Fire(Firing)
if Firing then
Animate:GetAnimation("10196909192", Viewmodel.Humanoid.Animator, true)
Animate:PlayAnimation()
else
Animate:StopAnimation()
end
end
Module Script
function module:GetAnimation(animationId, animator, Loop)
self.animation.AnimationId = "rbxassetid://" .. animationId
self.animationTrack = animator:LoadAnimation(self.animation)
self.animationTrack.Looped = Loop
end
function module:PlayAnimation()
self.animationTrack:Play()
end
function module:StopAnimation()
self.animationTrack:GetMarkerReachedSignal("Stop"):Wait()
self.animationTrack:Stop()
end