Issue with GetMarkerReachedSignal

I’m trying to use one animation track for several animations that are played out in a sequence, such as when one animation is complete then the next animation that will be played plays on the same track.

The issue is however that whenever i update the track to a new animationID, the “GetMarkerReachedSignal” stops working completely. Even if i change it to the same animationID, it stops working.

I do not know why or how the issue occurs, but one idea that i have is that when the animationID for the track updates its not treated as the “old” track despite having the same name, so the GetMarkerReachedSignal doesnt trigger because the updated track isnt considered the same as the old one. I do not know a lot about low level codes however so i may be completely wrong

I have also tried it with several animations, the issue occurs everytime.

Here is the code im using:

local RST = game.ReplicatedStorage
local C4M = require(RST.CCCCM) -- Just a module that checks conditions for things
local AnimationModule = require(RST.AnimationModule) -- Where i store the animations

local Animation = Instance.new("Animation")
Animation.AnimationID = AnimationModule["animation 1"] -- If its empty script wont work
-- The reason as to why it wouldnt work is that track would be nil, therefore no marker
local AnimationKey = {"animation 1", "animation 2", "animation 3", "animation 4"}
local track = humanoid:LoadAnimation(Animation)

local condition = "test" -- The test one always returns true

local animationNumber = 1 -- First animation in sequence

UIS.InputBegan:Connect(function(input)
	if input.UserInputType == Enum.KeyCode.Q then
		if C4M.Conditions(condition) == true then
			Animation.AnimationID = AnimationModule[AnimationKey[animationNumber]]
			track = humanoid:LoadAnimation(Animation) --Removing this line makes it work
			track:Play()                              -- But like its the entire purpose
		end
	end
end)

track:GetMarkerReachedSignal("hi"):Connect(function(param)
	print("hi")
	animationNumber += 1
end)

calling LoadAnimation causes for a new AnimationTrack to be made, overwriting the variable doesnt mean its the same object
Also, you should not be making a new AnimationTrack each time you press a key, store the tracks in a table and play those

2 Likes

Makes sense, but is there a way to still keep it short? Say there are 100 animations, do I need to store all the 100 different tracks in a table and create a GetMarkerReachedSignal for each one of them?

Yes, that is what you would need to do