Problems with :GetMarkerReachedSignal

Here is the script:

local humanoid = dummy’s humanoid
local boltoutsound = sound
local idleanim = idle animation
local boltoutanim1 = bolt animation

humanoid.DisplayDistanceType = Enum.HumanoidDisplayDistanceType.None

idleanim:Play()

while wait(2) do
local boltoutwait = boltoutanim1

boltoutwait:Play()
print("playing")

boltoutwait:GetMarkerReachedSignal("boltout"):Connect(function()
	boltoutsound:Play()
	print("reached")
end)

boltoutwait.Stopped:Wait()

print("finished")

end

Video:

Problem:

I think the problem is obvious, but if it’s not, well in the :GetMarkerReachedSignal function, the boltoutsound:Play() and print(“reached”) will be played the number of times, the function has been “fired”, or something like that. Any help suggestions?

2 Likes

It’s because you’re stacking connections, you can fix that by putting the connection on the outside of your while wait loop function or you can just disconnect the function after the stopped connection ends.

Edit: Also what’s the difference between GetMarkerReachedSignal and KeyframeReached, I never used get marker signal before.

5 Likes

Thx.But about the question about the KeyframeReached, I have no idea, sorry.

1 Like

You may not see this, but, you just solved the issue to my problem. I am completely new to animating and Moon Animator was giving me the biggest pain to actually add the signals to. I don’t know the entire difference, but my guess after looking around is that KeyframReached actually is for scanning for a certain name. In my case, “Charge” got created as its’ own keyframe, and it saw that rather than the regular “Keyframe”. I am horrible at explaining, but thank you.