I was making the reload sound of the weapon using the GetMarkerReachedSignal from the animation. However, if you run the animation multiple times, the sound overlaps several times. In another attempt, I tried to use Disconnect, but the sound is played multiple times again(I used Track.Stopped too, When reload weapon multiple times before animation stops). GetMarkerReachedSignal:Wait(), but there is no way to get the number of events in the animation…
How can i fix this problem?
function playAnimation(AnimationName)
for i,v in pairs(Animations) do
if v[1] == AnimationName then
v[2]:Play(v[3][1],v[3][2],v[3][3])
local AnimSoundEvent = v[2]:GetMarkerReachedSignal("sound"):Connect(function(value)
if value then
PlayReloadSound(value,RemoteKey)
end
end)
v[2].Stopped:Connect(function()
AnimSoundEvent:Disconnect()
end)
end
end
end
Edit: I posted my code
Thanks for reading.