I have an attack module with this snippet in, and is fired just once every 10 seconds.
I would like when the animation reaches the “Damage” KeyframeEvent to fire the “DealDamage()” function (declared out of the snippet)
Its just not firing. Here’s my snippet and my animation.
local GrabConnect = Track:GetMarkerReachedSignal("Grab"):Connect(FindAndGrabPerson)
local DamageConnect = Track:GetMarkerReachedSignal("Damage"):Connect(DealDamage) -- Here
-- Doit
Track:Play()
Track.Stopped:Wait()
-- End
GrabConnect:Disconnect()
DamageConnect:Disconnect()
From what I can gather, there seems to be an issue with GetMarkerReachedSignal failing to work if the KeyframeMarker happens to be on the last frame of the animation
If the condition above is valid for Damage, then in-order to fix your issue, you’ll need to connect the DealDamage function to the track’s Stopped event instead of the event returned by GetMarkerReachedSignal("Damage")
(Alternatively, you can call the DealDamage function directly after the Track.Stopped:Wait() line if the function doesn’t contain anything that yields, which might interfere with the rest of the code written below where you call it)
Thanks for replying! Sorry for the late response -
The (two) damage key frame events happen throughout the animation; the first is called “Grab” and the last two are called “Damage”.
I get what you mean but I’d like to deal damage on each of those key frames as It’ll add some detail, but I could just deal the total damage it would have done at the end if we don’t come to a fix.
By the way, just for context the “Grab” one above it works which is why I’m so confused
I might try task.wait() in between the connects and maybe that could work, brb
Update - It didn’t work
Even though it’s deprecated, you could try using the Track.KeyframeReached event, hopefully it will detect the markers correctly for you
—- @zanmontanem If the test above unfortunately fails, then make sure that the animation you’re using does indeed have the markers (if you’ve recently updated the animation, you could be experiencing some desynchronization issues while Roblox’s servers finish processing the new version), or that there aren’t any issues with their names such as any typos or using a different capitalization