How do i get access to roblox's RunAnim's "AnimationTrack" in roblox's Animate script

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I’m making a script that plays and Audio for when the player’s “Right Foot” and “Left Foot” touches the ground. I’m using a Custom animation with a labeled KeyFrame Called “Right Foot” and “Left Foot”.
    https://gyazo.com/a7c3d3bc822673a5fd13e68f56e87737

The main problem is getting the AnimationTrack since I am using Roblox’s default “Animate” script. I know that I can make my own custom animation and just put it inside the Animate script’s values. But I need to get access to that “RunAnim” AnimationTrack. I tried looking inside the “Animate” script but it was too hard for me to comprehend the codes in it and couldn’t find where the “RunAnim” animation track is.

  1. What is the issue? Include screenshots / videos if possible!

This is the “Animate” script that Roblox uses, I changed the animation IDs inside the script and in the Values of the script as well(run>RunAnim)
https://gyazo.com/d7d6ecdac1857e4365414f40e68d150e

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

I’ve read that u can get the animations that are played in the humanoid using lua Humanoid:GetPlayingAnimationTracks() so I did, here is my script:

Player = game.Players.LocalPlayer

Character = Player.Character
function test(x)
	x:GetMarkerReachedSignal("Right Foot"):Connect(function()
		print("Right Foot")
	end)
	x:GetMarkerReachedSignal("Left Foot"):Connect(function()
		print("Left Foot")
	end)
end

Character.Humanoid.Running:connect(function(Speed)
	if Speed > 0 then
		local idk = Character.Humanoid:GetPlayingAnimationTracks()
		for i,v in pairs(idk) do
			if v.Name == "RunAnim" then
				test(v)
			end
		end
	end
end)

https://gyazo.com/c4022350583f0799af52ea1ec1ee32bd

Now in this script what it’s supposed to do is print “Left Foot” and “Right Foot” in a pattern, but there’s a bug that prints each one 10x, which is not what I want. (Note: although, this approach gave me close results)

I have a feeling that I’m approaching this issue incorrectly, so what do I do? How do I get access to those AnimationTracks

Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.

Disconnect the both GetMarkerReachedSignal():Connect() after function test(x) is done, otherwise you will just start stacking connections and print more than desired.

Player = game.Players.LocalPlayer
local connections = {};

local function disconnect() -- Not sure if im doing this right, lol
      for i,v in pairs (connections) do
          v:Disconnect()
      end
      for i=1,#connections do -- Prevent the table "connections" stacking, so we're clearing it out!
            table.remove(connections,1)
      end
end

Character = Player.Character
function test(x)
	connections[#connections+1] = x:GetMarkerReachedSignal("Right Foot"):Connect(function()
		print("Right Foot")
	end)
	connections[#connections+1] = x:GetMarkerReachedSignal("Left Foot"):Connect(function()
		print("Left Foot")
	end)
end

Character.Humanoid.Running:connect(function(Speed)
	if Speed > 0 then
		local idk = Character.Humanoid:GetPlayingAnimationTracks()
		for i,v in pairs(idk) do
			if v.Name == "RunAnim" then
				test(v)
			end
		end
	end
end)

Why not just use Humanoid.Running? You don’t need to edit the animation script, though it probably won’t be in sync at all.

You need to add a debounce in your test function because its prolly firing multiple times. Something like this:

local db = false
function test(x)
        x:GetMarkerReachedSignal("Right Foot"):Connect(function()
if (db == false) then
db = true
		print("Right Foot")
db = false -- Set to false so it runs again
	end)
	x:GetMarkerReachedSignal("Left Foot"):Connect(function()
--REPEAT HERE
		print("Left Foot")
	end)
end;
--

Wrote this in its most basic form so you can understand. The purpose of a debounce is to prevent the script from running multiple times by setting the debounce to true or false. In pseudo code:
If db is not true then
print(‘right foot’)
set db to false

As for the running part, humanoid.Running already fires when the player is running.

character.Humanoid.Running:connect(function(speed)
--code
end)

Honestly, i didn’t even know that “Disconnect()” was a thing.It’s amazing how u can disconnect an event as well. Wow this changes everything for my coding skills. Thank you by the way, much appreciated.

Ahh yes, i forgot about how useful debounce can be somtimes. But sadly i’m still facing bugs, but debounce somehow made it better i guess. Thank you a lot! :slight_smile: