sound effect is playing at wrong time

Hey Guys!
I’m following Brackeys beginner tutorial and I reached to sound effects and “audio in unity” part.
So I made the sound class and AudioManager just like tutorial, and I made 5 sounds for: Theme, Crash, falling, Victory and Click (for clicking buttons in menu)
and btw I have 3 scenes: Menu, level 1 and Credits
everything is working fine except my falling sound which is not playing when the cube falls from ground. its playing when Scene change from level 1 to credit.
Can anyone help me?

and here are my audio manager and playermovement scripts:

using UnityEngine;
using System;
using UnityEngine.Audio;

public class AudioManager : MonoBehaviour
{
    public Sound[] sounds;
    public static AudioManager instance;
    void Awake()
    {
        if (instance == null)
            instance = this;
        else
        {
            Destroy(gameObject);
            return;
        }
        DontDestroyOnLoad(gameObject);
        foreach(Sound s in sounds)
        {
            s.source = gameObject.AddComponent<AudioSource>();
            s.source.clip = s.clip;
            s.source.loop = s.loop;
            s.source.volume = s.volume;
            s.source.pitch = s.pitch;
        }
    }

    void Start()
    {
        Play("Theme");
    }
    public void Play (string name)
        {
            Sound s=Array.Find(sounds, sound => sound.name == name);
        if (s == null)
        {
            Debug.LogWarning("Sound: " + name + " not found!");
            return;
        }
            s.source.Play();
        }
}


using UnityEngine;


public class PlayerMovement : MonoBehaviour
{
    public Rigidbody rb; //This is a reference to the Rigidbody component called "rb"
    public float forwardForce = 3200f;
    //public float backwardForce = 3500f;
    public float sideForce = 3200f;
    public Transform Ground;
    void Start()
    {
    }

    /*void FixedUpdate()
    {
        rb.AddForce(0, 0, Input.GetAxis("Vertical") * forwardForce * Time.deltaTime, ForceMode.VelocityChange);
        rb.AddForce(Input.GetAxis("Horizontal") * sideForce * Time.deltaTime, 0, 0, ForceMode.VelocityChange);
        
    }*/

    void FixedUpdate()
    {
        
        if (Input.GetKey("w"))
        {
            rb.AddForce(0, 0, forwardForce * Time.deltaTime);
        }
        if (Input.GetKey("s"))
        {
            rb.AddForce(0, 0, -forwardForce * Time.deltaTime);
        }
        if (Input.GetKey("d"))
        {
            rb.AddForce(sideForce * Time.deltaTime, 0, 0);
        }
        if (Input.GetKey("a"))
        {
            rb.AddForce(-sideForce * Time.deltaTime, 0, 0);
        }
        if(rb.position.y<Ground.localScale.y/2+ transform.localScale.y/2)
        {
            FindObjectOfType<GameManager>().GameOver();
            FindObjectOfType<AudioManager>().Play("Falling");
        }
    }
}

if(rb.position.y(<)Ground.localScale.y/2+ transform.localScale.y/2)
{
FindObjectOfType().GameOver();
FindObjectOfType().Play(“Falling”);
}


This code right here is sending red flags to me. For example, the if statement has no ==. How would it know what to check for? Also, why do you have rb.position.y with a < after it? That wouldn’t work. Also, if you’re calling the GameOver method right before the falling audio plays, how would it play? However, even if you put the falling audio before the GameOver method, unless the GameOver method took a lot of time to do, your audio still wouldn’t play.


Try doing this instead to see if it works!

if(rb.velocity.y < 0)
{
FindObjectOfType().Play(“Falling”);
}

//Create a box collider that is a trigger underneath the map or something, or wherever you need it in your case, and then put another script on it that will call the GameOver method if it collides with the player.


I hope this helps!

well thanks for your help bro @ZachCreates

I changed if statement to rb.velocity.y < 0 (of course it is more clear tnx.)
I made a plane for ground and its script (GroundTrigger) and these are my results:
(PM for playermovement and gt for ground trigger):

    1. 
    PM:
            if(rb.velocity.y < 0)
            {
                FindObjectOfType<AudioManager>().Play("Falling");
                FindObjectOfType<GameManager>().GameOver();
            }
    didnt work
    
    2. 
    PM:
            if(rb.velocity.y < 0)
            {
                FindObjectOfType<AudioManager>().Play("Falling");
    
            }
    GT:
            if (other.CompareTag("Player"))
            {
                FindObjectOfType<GameManager>().GameOver();
            }
    didnt work

    3. 
    PM:
            if(rb.velocity.y < 0)
            {
                FindObjectOfType<GameManager>().GameOver();
            }
    GT:
            if (other.CompareTag("Player"))
            {
                FindObjectOfType<AudioManager>().Play("Falling");
            }
    worked

    4.
    GT:
            if (other.CompareTag("Player"))
            {
                FindObjectOfType<AudioManager>().Play("Falling");
                FindObjectOfType<GameManager>().GameOver();
            }
worked

but my question is WHY?
i mean whats the difference for example between 1st and 4th code?
if statement (velocity) becomes true exactly when the player falls off so why first or second codes are not working correct?
thanks a lot!