Animation/Variable Organization

i’m currently making a framework that has a set of animations that play after another but trying to add features to an animation even is frustrating to copy and paste ALL the code over to the others, is there a way i can merge the swing1/swing2/swing3/swing4 all together?
image

1 Like

Just put the repeating part in a function

--set ups the markers for a track
function createMarkerEvents(animationTrack)

  animationTrack:GetMarkerReachedSignal("exampleName"):Connect(function()
  end)

end

--then call the function for each track
createMarkerEvents(Swing1)
createMarkerEvents(Swing2)
createMarkerEvents(Swing3)

--could also do something like this
local animationTracks = {swing1, swing2, swing3}

for _, animationTrack in ipairs(animationTracks) do
  createMarkerEvents(animationTrack)
end