local hit_connection
hit_connection = stand_animation:GetMarkerReachedSignal("Hit"):Connect(function() -- hit
create_sound(8701825353, 0.8, 0.9)
hit_connection:Disconnect() -- once this is fired the other events wont run, need to bypass this
end)
I could be wrong, but as far as I understand, if you do this:
stand_animation:GetMarkerReachedSignal("Hit"):Connect(function() -- hit
create_sound(8701825353, 0.8, 0.9)
end)
And when the Model that holds the Humanoid > Animator > AnimationTrack is destroyed, the connection gets disconnected
If you store the connection inside a variable as you did:
local hit_connection = stand_animation:GetMarkerReachedSignal("Hit"):Connect(function()
create_sound(8701825353, 0.8, 0.9)
end)
Even if the Model holding the Animator is destroyed the connection still in memory (possibly causing memory leak), and you can manually disconnect it whenever you need. For example, the Model (Player or NPC) is never destroyed but you want to stop listening the MarkerReachedSignal.
The code you are showing just, store the connection into a variable and its disconnected after the first “Hit” marker reached, causing all other markers to not trigger the function connected to it.