The usual response I see for this is to check if the player’s velocity is less than 1. This is a sloppy solution with tons of problems – the main one being that if they’re standing on a moving platform, the script will assume they’re not in the idle state.
Maybe find the part the player is standing on (raycast), then compare the difference in speed between the player and that part? On terrain, you can determine the state just by player velocity.