Spawned sounds keep playing on each other

I want to make the code so it plays the sound only when the event fires, not all the time.
Here’s my script:

spawn(function()
	while true do
		
		while track.Animation.AnimationId == Animations.Running.Animation.AnimationId do
			
			local connection
			
			connection = track:GetMarkerReachedSignal("Step"):Connect(function(frame)
				connection:Disconnect()
				spawn(function()
					local sound = steps[math.random(1,#steps)]:Clone()
					sound.Parent = script.Parent.View
					sound:Play()
					wait(sound.TimeLength)
					sound:Destroy()
				end)
				
			end)
			
			wait()
			
		end
		
		wait(0.1)
		
	end
end)

Help is appreciated.

maybe debounce will help you solve this:

local debounce = false

spawn(function()
	while true do
		
		while track.Animation.AnimationId == Animations.Running.Animation.AnimationId and debounce==false  do
			debounce=true
			local connection
			
			connection = track:GetMarkerReachedSignal("Step"):Connect(function(frame)
				connection:Disconnect()
				spawn(function()
					local sound = steps[math.random(1,#steps)]:Clone()
					sound.Parent = script.Parent.View
					sound:Play()
					wait(sound.TimeLength)
					sound:Destroy()
                    debounce=false
				end)
				
			end)
			
			wait()
			
		end
		
		wait(0.1)
		
	end
end)

There should be no debounce. I just want the event to get fired when the robot steps ONLY.

have you tried to try for example Player.Character.Humanoid.Running:Connect()?

If not, then try to do it, it will react to the movement of the character, that is, for example:

Player.Character.Humanoid.Running:Connect(function(speed)
    if speed>0 then
        RunLoopAnmation() --will run a loop of your animation
    else
        StopLoopAnimation() --will stop a loop of your animation
    end
end)

would definitely use this solution as loops aren’t the solution to every problem