Getmarkerreachedsignal firing immediately despite the marker being at the end of the animation

I’m making a tool play an animation when it is equipped

When the tool is equipped however, the code that is supposed to be after the signal is fired happens instantly

I have redone the animation 3 times, renamed the marker, and replaced it in different locations near the end of my animation however nothing seems to prevent the signal from firing instantly.


This video shows that the instant moment that i equip the tool it fires the marker

Another thing to note is that it quite literally does not matter what i call the eventmarker in the getmarkerreached signal function. Regardless of what i call it, it will still print “Equipped” despite the if function

GetMarkerReachedSignal is a signal, so you have to connect it, currently you checking if it exist, not if it fired

1 Like

Animator:GetMarkerReachedSignal is an event, not a function. To fix it you need to wait until the event fires.

Fix:

Tool.Equipped:Connect(function(mouse: Mouse) 
	Animator:Play()
	Animator:GetMarkerReachedSignal("Equip"):Once(function(...: any) 
		Equipped = true	
	end)
end)
2 Likes

should not connect functions in connections, can cause memory leaks

1 Like

Edited it so it auto disconnects. Will probably need more logic for when the player unequips before the event fires so that the equipped variable isn’t true

2 Likes

So i shouldn’t use something like this?

image

Just switch “Connect” to “Once”. The difference is that after the event fires it auto disconnects itself

1 Like

if you will listen to the event once its good, but if you wanna use it multiple times, its better to take out any connection inside a connection

1 Like

ohhh i see thank you guys so much! :smile: :+1:

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.