audio doesn't play on movement

i try to play footsteps audio on movement but it doesn’t play, can someone help please?

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class footsteps2 : MonoBehaviour
CharacterController player;
bool isMoving = false;
AudioSource foot;
// Start is called before the first frame update
void Start()
foot = GetComponent();
player = GetComponent();


// Update is called once per frame
void Update()
    if (player.velocity ==
        isMoving = false;



It could be multiple things. Are you getting any errors or is it just not working?

  1. make sure you can hear the sound.
    Set your audio source to play
    automatically and verify that the
    sound effect works.
  2. make sure
    you code is reaching the play
    function. Put a log right before
    foot.Play(); and see if it gets