Which method would be better to use for counting footsteps?

Howdy, so I’m creating a game with a leaderstat that increases everytime you take a step. The game is R6. After digging through the Forum, I’ve found two methods to do this.

  • The first uses the GetMarkerReachedSignal function of AnimationTrack, where you place markers in a walking animation at the points where the feet contact the ground. However I’ve heard that you can just quickly tap W and never get to the markers, so the counter won’t ever increase.

  • The second constantly counts if a player has moved in studs and counts them as steps, but I’ve heard from friends that it’s complicated to implement and if the player teleports it counts that as a step.

So could anyone tell me which method would be more reliable to use?
Or, is there a way to detect if a player is holding down the W key and it starts incrementing the value every couple milliseconds or something until the player lets go.

Get the animation length, divide by two and when it’s gone longer than that time, add to the count.
Ooor… you could add an event to when the walk sound gets played and add to the count.
Keep this server-side!

I don’t see how this would be complicated to implement. Just keep track of the player’s position when the last step was counted (or the position at which they spawned in) and wait until they’ve moved far enough to have made a step.

Teleporting is a nonissue because either (A) teleporting is not a part of your game, so the only people who will be teleporting are exploiters or people respawning, or (B) you can just have a flag or something that tells the step counter “Hey this player is teleporting, please don’t count their movement as steps until they’ve finished teleporting!”

1 Like

This answer really depends on how essential the accuracy of the system is. If you want every footstep to be counted, your most accurate method would be raycasting down from each foot every frame to see if they are touching the ground.

However in terms of a les accurate yet a lot more practice solution you would just time how long it has been between the running animation starting and stopping and calculating it from that.

Went with the sound method. Turns out walking sounds don’t play until other actions such as jumping happen. Also had to use a Remote Event.