GetMarkerReachedSignal not working

Hello! So i made a Momentum script for my character in my 3D platformer, but i found out that the footstep sound doesn’t sync with the speed of the character. I looked for solutions till i found GetMarkerReachedSignal.
I managed to make it work, i added the markers into both the Walking and Running animations, and i named them “Step”. Now for some reason the code doesn’t work, there is no error in the output, i have made sure that i added the markers and got their names correct, i even reuploaded the animations, but still to no avail.
I have added a print() to the function but it doesn’t print anything. I think it has something to do with how i defined the animations, but again, i’m not sure.

Here’s the code :

--//Services//--
local TweenService = game:GetService("TweenService")
local RunService = game:GetService("RunService")
local Players = game:GetService("Players")
--//Variables//--
local Player = Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Animate = Character:WaitForChild("Animate")
local Walk = Animate.walk
local Run = Animate.run
local Root = Character:WaitForChild("HumanoidRootPart")
local Humanoid = Character:WaitForChild("Humanoid")
local Head = Character:WaitForChild("Head")
local Face = Head.Face
local Landing = script:WaitForChild("Landing")
local LandingAnim = Humanoid:LoadAnimation(Landing)
local LandingSound = Root:WaitForChild("ND_Land")
local LeftFoot = Character:WaitForChild("LeftFoot")
local RightFoot = Character:WaitForChild("RightFoot")
local Footstep = Root:WaitForChild("ND_Step")
local Impact1 = Root:WaitForChild("ND_Thump1")
local Impact2 = Root:WaitForChild("ND_Thump2")
local ImpactSounds = {Impact1, Impact2}
local HitFloor1 = script:WaitForChild("HitFloor1")
local HF1Anim = Humanoid:LoadAnimation(HitFloor1)
local WalkAnim = Humanoid:LoadAnimation(Walk.WalkAnim)
local RunAnim = Humanoid:LoadAnimation(Run.RunAnim)
--//Functions//--
------------------------------------------------------
local function onWalkOrRunPlayed()
	print("step")
	Footstep:Play()
end
------------------------------------------------------
local function onHumanoidRunning(Speed)
	if Speed > 6 then
		local DustPart1 = Instance.new("Part", LeftFoot)
		local Mesh1 = Instance.new("SpecialMesh", DustPart1)
		Mesh1.MeshId = "rbxassetid://13977814347"
		Mesh1.Scale = Vector3.new(0.04, 0.04, 0.04)
		DustPart1.Name = "DP1"
		DustPart1.Size = Vector3.new(0.75, 0.5, 0.75)
		DustPart1.Position = LeftFoot.Position
		DustPart1.BrickColor = BrickColor.new(255, 255, 255)
		DustPart1.CanCollide = false
		DustPart1.CanTouch = false		
		DustPart1.Anchored = true
		----------------------------------------------------
		local DustPart2 = Instance.new("Part", RightFoot)
		local Mesh2 = Instance.new("SpecialMesh", DustPart2)
		Mesh2.MeshId = "rbxassetid://13977814347"
		Mesh2.Scale = Vector3.new(0.04, 0.04, 0.04)
		DustPart2.Name = "DP2"
		DustPart2.Size = Vector3.new(0.75, 0.5, 0.75)
		DustPart2.Position = RightFoot.Position
		DustPart2.BrickColor = BrickColor.new(255, 255, 255)
		DustPart2.CanCollide = false
		DustPart2.CanTouch = false		
		DustPart2.Anchored = true
		----------------------------------------------------
		DustPart1:Clone()
		DustPart2:Clone()
		local TweenInform = TweenInfo.new(0.5, Enum.EasingStyle.Linear, Enum.EasingDirection.In)
		local TweenTransparency1 = TweenService:Create(DustPart1, TweenInform, {Transparency = 1})
		local TweenSize1 = TweenService:Create(Mesh1, TweenInform, {Scale = Vector3.new(0.08, 0.08, 0.08)})
		local TweenTransparency2 = TweenService:Create(DustPart2, TweenInform, {Transparency = 1})
		local TweenSize2 = TweenService:Create(Mesh2, TweenInform, {Scale = Vector3.new(0.08, 0.08, 0.08)})
		TweenSize1:Play()
		TweenTransparency1:Play()
		TweenSize2:Play()
		TweenTransparency2:Play()
		task.wait(0.5)
		DustPart1:Destroy()
		DustPart2:Destroy()
	end
end
----------------------------------------------------------
local function onLandedNormal(_, State)
	if State == Enum.HumanoidStateType.Landed then
		LandingAnim:Play()
		LandingAnim:AdjustSpeed(1.5)
		LandingSound.PlaybackSpeed = math.random(10,12)/10
		LandingSound:Play()
		---------------------------------------------------
		local CloudPart = Instance.new("Part", Character)
		CloudPart.Anchored = true
		CloudPart.CanCollide = false
		CloudPart.CanTouch = false
		CloudPart.Position = Root.Position - Vector3.new(0, 2.5, 0)
		CloudPart.Size = Vector3.new(2.5, 2.5, 2.5)
		CloudPart.Material = Enum.Material.Neon
		CloudPart.BrickColor = BrickColor.new(255, 255, 255)
		--------------------------------------------------------
		local CloudMesh = Instance.new("SpecialMesh", CloudPart)
		CloudMesh.Scale = Vector3.new(0.05, 0.025, 0.05)
		CloudMesh.MeshId = "rbxassetid://11978515144"
		--------------------------------------------------------
		local TweenService = game:GetService("TweenService")
		local TweenInfo1 = TweenInfo.new(0.25, Enum.EasingStyle.Linear, Enum.EasingDirection.In)
		local TweenSize = TweenService:Create(CloudMesh, TweenInfo1, {Scale = Vector3.new(0.15, 0.025, 0.15)})
		local TweenTransparency = TweenService:Create(CloudPart, TweenInfo1, {Transparency = 1})
		TweenSize:Play()
		TweenTransparency:Play()
		task.wait(0.3)
		CloudPart:Destroy()
	end
end
-----------------------------------------------------
HF1Anim.Priority = Enum.AnimationPriority.Action4
local function onLandedDamage(_, State)
	-----------------------------------------------------
	if State == Enum.HumanoidStateType.Landed then
		local Height = -Root.Velocity.Y
		-----------------------------------------------------
		if Height >= 150 then
			local Damage = (Height / 80) ^ 4.5
			local RandomSound = ImpactSounds[math.random(1, #ImpactSounds)]
			RandomSound:Play()
			Humanoid:TakeDamage(Damage)
			HF1Anim:Play()
			HF1Anim:AdjustSpeed(0.2)
			Humanoid.WalkSpeed = 0
			Humanoid.JumpPower = 0
			Face.Texture = "rbxassetid://14179652797"
			task.wait(1.5)
			Humanoid.WalkSpeed = 26
			Humanoid.JumpPower = 50
			Face.Texture = "rbxassetid://14179652498"
		end
	end
end
---------------------------------------------------------------
local function onHumanoidNotRunning()
	Footstep.Playing = false
	local DustPart1 = LeftFoot:WaitForChild("DP1", math.huge)
	local DustPart2 = LeftFoot:WaitForChild("DP2", math.huge)
	DustPart1:Destroy()
	DustPart2:Destroy()
end
---------------------------------------------------------------
--//Connections//--
Humanoid.Running:Connect(onHumanoidRunning)
Humanoid.Jumping:Connect(onHumanoidNotRunning)
Humanoid.FreeFalling:Connect(onHumanoidNotRunning)
Humanoid.Swimming:Connect(onHumanoidNotRunning)
Humanoid.Climbing:Connect(onHumanoidNotRunning)
Humanoid.StateChanged:Connect(onLandedNormal)
Humanoid.StateChanged:Connect(onLandedDamage)
WalkAnim:GetMarkerReachedSignal("Step"):Connect(onWalkOrRunPlayed)
RunAnim:GetMarkerReachedSignal("Step"):Connect(onWalkOrRunPlayed)
2 Likes

Does your RunAnim or WalkAnim start to play?

2 Likes

Yes, but the GetMarkerReachedSignal doesn’t work at all.

2 Likes

Look if it’s spelled correctly. If it is, can you show the window of the animation event?

3 Likes

Wait nevermind, you are only playing the Footstep? This is not the WalkAnim or RunAnim. GetMarkerReachedSignal only works if the animation is played and reached that moment. Be sure to play the animation.

image

2 Likes

I was also curious, because I can’t find where you play animations

2 Likes

So you mean i should put that the function and the connection into the onHumanoidRunning event?

2 Likes

It is spelled correctly. Here are some screenshots.


2 Likes

you never played WalkAnim and RunAnim at all!

2 Likes

Hmm, that is very strange. Re-publish the animation and make sure the IDs are the same? The only reason I can think for this happening is that the animation being played is a different asset from the one with the events.

2 Likes

Because it plays automatically when the player moves

2 Likes

how so???

2 Likes

Oh, i don’t know, probably because it’s in the Animate script?

2 Likes

is the script above the animate script itself or different script?

2 Likes

A different script that is supposed to play the sounds when the player runs or walks.

2 Likes

just because you load the same animation in the same humanoid but in different scripts, doesn’t mean you will get the same AnimationTrack.

instead, put the marker event in the animate script

3 Likes

Uh oh, I think I know what’s going on.

The WalkAnim and RunAnim in the script you have refers to specific AnimationTrack objects returned by Animator:LoadAnimation:

The Animate script does it’s own :LoadAnimation, and so the one in your script never actually plays, the one in the Animate script does.

You need to get rid of the Animate script and handle the walk/run animations in your own script so that the references are correct.

Or do that… much simpler probably.

1 Like

Are you sure i can’t just move the GetMarker thingy to the Animate script?

1 Like

Alright thanks, i 'll try that.

2 Likes

It did not work for some reason.

1 Like