Ads keep us online. Without them, we wouldn't exist. We don't have paywalls or sell mods - we never will. But every month we have large bills and running ads is our only way to cover them. Please consider unblocking us. Thank you from GameBanana <3

How to randomize lose sounds when caught by Baldi

A Tutorial for Baldi's Basics

No ads for members. Membership is 100% free. Sign up!
This is my first tutorial so it could be a bit wonky and messed up, you can help me on some parts where I messed up if you'd like, only if I did mess up though.

Step 1: Open up your GameControllerScript (GCS) and locate where it says
 if (this.player.gameOver)

Step 2: Under the bracket beneath the code above copy and paste this code   

            Time.timeScale = 0f; //Pause the game
            this.audVal = Mathf.RoundToInt(UnityEngine.Random.Range(1f, 5f));
            this.gameOverDelay -= Time.unscaledDeltaTime; if (!this.audioDevice.isPlaying)
            {
                this.audioDevice.PlayOneShot(this.LoseSounds[this.audVal]); //Play the jumpscare sound in variations
            }
            if (this.gameOverDelay <= 0f)
            Time.timeScale = 0f; //Pause the game
            this.audVal = Mathf.RoundToInt(UnityEngine.Random.Range(1f, 5f));
            this.gameOverDelay -= Time.unscaledDeltaTime; if (!this.audioDevice.isPlaying)
            {
                this.audioDevice.PlayOneShot(this.LoseSounds[this.audVal]); //Play the jumpscare sound in variations
            }
            if (this.gameOverDelay <= 0f)

Or make it look like how it does in the photo. Yes you have to remove the code that's already there or it will make errors.

Step 3: Go to the very bottom of the script and add what you see in the photo boxed, so I mean. Add the following from below 

    public AudioClip[] LoseSounds = new AudioClip[5];

    public int audVal;

Step 4: Go to the "GameController" object in your project (we are done with code for now unless you have errors) and click on it then scroll down till you see something that says "Lose Sounds" then click on it!

Step 5: Add your sounds into the empty slots, and then you can go test them out! The sounds can even be from BBKED or BBFGPD. If you want.
Sign up to access this!
  • DOI MODDER avatar
    DOI MODDER Joined 17d ago
    Offline
    146 points Ranked 60874th
    access_time 17d
    Umm.. I do it in a different way and it still works;

    if (this.player.gameOver)
        {
            Time.timeScale = 0f;
            this.gameOverDelay -= Time.unscaledDeltaTime;
            if (!this.jumpscareSoundPlayed)
            {
                this.audioDevice.Stop();
                this.audioDevice.loop = false;
                this.audioDevice.volume = 1f;
                int num = Mathf.RoundToInt(UnityEngine.Random.Range(0f, 8f));
                this.audioDevice.PlayOneShot(this.aud_Jumpscares[num]);
                this.jumpscareSoundPlayed = true;
            }
            if (this.gameOverDelay <= 0f)
            {
                if (this.mode == "endless")
                {
                    if (this.notebooks > PlayerPrefs.GetInt("HighBooks"))
                    {
                        PlayerPrefs.SetInt("HighBooks", this.notebooks);
                        PlayerPrefs.SetInt("HighTime", Mathf.FloorToInt(this.time));
                        this.highScoreText.SetActive(true);
                    }
                    else if (this.notebooks == PlayerPrefs.GetInt("HighBooks") & Mathf.FloorToInt(this.time) > PlayerPrefs.GetInt("HighTime"))
                    {
                        PlayerPrefs.SetInt("HighTime", Mathf.FloorToInt(this.time));
                        this.highScoreText.SetActive(true);
                    }
                    PlayerPrefs.SetInt("CurrentBooks", this.notebooks);
                    PlayerPrefs.SetInt("CurrentTime", Mathf.FloorToInt(this.time));
                }
                Time.timeScale = 1f;
                SceneManager.LoadScene("ElevatorOutro");
            }
        }
        else if (this.player.gameOverMarii)
        {
            Time.timeScale = 0f;
            this.gameOverDelay -= Time.unscaledDeltaTime;
            if (!this.jumpscareSoundPlayed)
            {
                this.audioDevice.Stop();
                this.audioDevice.loop = false;
                this.audioDevice.volume = 1f;
                int num2 = Mathf.RoundToInt(UnityEngine.Random.Range(0f, 8f));
                this.audioDevice.PlayOneShot(this.aud_Jumpscares[num2]);
                this.jumpscareSoundPlayed = true;
            }
            if (this.gameOverDelay <= 0f)
            {
                if (this.mode == "endless")
                {
                    if (this.notebooks > PlayerPrefs.GetInt("HighBooks"))
                    {
                        PlayerPrefs.SetInt("HighBooks", this.notebooks);
                        PlayerPrefs.SetInt("HighTime", Mathf.FloorToInt(this.time));
                        this.highScoreText.SetActive(true);
                    }
                    else if (this.notebooks == PlayerPrefs.GetInt("HighBooks") & Mathf.FloorToInt(this.time) > PlayerPrefs.GetInt("HighTime"))
                    {
                        PlayerPrefs.SetInt("HighTime", Mathf.FloorToInt(this.time));
                        this.highScoreText.SetActive(true);
                    }
                    PlayerPrefs.SetInt("CurrentBooks", this.notebooks);
                    PlayerPrefs.SetInt("CurrentTime", Mathf.FloorToInt(this.time));
                }
                Time.timeScale = 1f;
                SceneManager.LoadScene("GameOver");
            }
        }

    then I put  // Token: 0x04000439 RID: 1081
    public bool jumpscareSoundPlayed;
     and 

    // Token: 0x0400045F RID: 1119
    public AudioClip[] aud_Jumpscares = new AudioClip[9];

    then i can put as many jumpscare sounds as i want.
    • Disagree x 1
    BRUH Detention 4 u LOL! avatar
    Mantra
    BRUH Detention 4 u LOL!
    URL to post:
  • Saintza_YT avatar
    Saintza_YT Joined 2y ago
    Sleeping At Now
    348 points Ranked 49835th
    12 medals 1 legendary 1 rare
    • Returned 5000 times Medal icon
    • Returned 1000 times Medal icon
    • Returned 100 times Medal icon
    • Submitted 5 Gamefiles Medal icon
    • One month a member Medal icon
    • Thanked 5 submitters Medal icon
    access_time 21d
    It looks like I wrote this with the mental state of a five year old... I was really tired so that is probably the case idk
    Maybe I will finish early. avatar
    Mantra
    Maybe I will finish early.
    URL to post:

Embed

Share banner
Image URL
HTML embed code
BB embed code
Markdown embed code

Credits

Key Authors
Saintza_YT
Saintza_YT Joined 2y ago
Offline
348 points Ranked 49835th
12 medals 1 legendary 1 rare
  • Returned 5000 times Medal icon
  • Returned 1000 times Medal icon
  • Returned 100 times Medal icon
  • Submitted 5 Gamefiles Medal icon
  • One month a member Medal icon
  • Thanked 5 submitters Medal icon
Creator

Submitter

Saintza_YT avatar
Saintza_YT Joined 2y ago
Sleeping At Now
348 points Ranked 49835th
12 medals 1 legendary 1 rare
  • Returned 5000 times Medal icon
  • Returned 1000 times Medal icon
  • Returned 100 times Medal icon
  • Submitted 5 Gamefiles Medal icon
  • One month a member Medal icon
  • Thanked 5 submitters Medal icon
Saintza_YT
Creator
Sign up to access this!
Sign up to access this!
Sign up to access this!

Game

Sign up to access this!

Category

Details

Difficulty Level
Intermediate

Attributes

Share

  • Share on Reddit
  • Share on Twitter
  • Share on Facebook
  • 2
  • 617
  • 5
  • 21d
  • 20d

WiPs by Submitter

More Decompile Tutorials