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

Custom Event Script

A Config Script for Baldi's Basics

No ads for members. Membership is 100% free. Sign up!
84 2 kb Raw Code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
using System.Collections;
using UnityEngine;
using UnityEngine.UI;

public class EventScript : MonoBehaviour
{
  private float eventTimer;
  private float eventCooldown;
  private int eventChance;
  private string[] eventTexts
  {

  };
  private bool eventStarted;
  public Image hudBackground;
  public Text hudText;
  public AudioClip eventBell;
  public AudioSource audioDevice;

  private void Update()
  {
     if (this.eventCooldown > 0f)
     {
        this.eventCooldown -= Time.deltaTime;
     }
     else
     {
       if (this.eventStarted)
       {
          this.StopEvent();
       }
     }
     if (this.eventTimer > 0f)
     {
        this.eventTimer -= Time.deltaTime;
     }
     else
     {
       if (!this.eventStarted)
       {    
 StartCoroutine(this.StartEvent());
       }
     }
  }
  IEnumerator StartEvent()
  {
    this.eventStarted = false;
    this.audioDevice.PlayOneShot(this.eventBell);
    yield return new WaitForSeconds(3f);
    this.eventChance = UnityEngine.Random.Range(0, 2);
this.hudBackground.gameObject.SetActive(true);
     this.hudText.text = this.eventTexts[this.eventChance];
     if (this.eventChance == 0)
     {

     }
     if (this.eventChance == 1)
     {

     }
     if (this.eventChance == 2)
     {

     }
     this.eventTimer = UnityEngine.Random.Range(30f, 45f);
     yield break;
  }
  void StopEvent()
  {
     if (this.eventChance == 0)
     {

     }
     if (this.eventChance == 1)
     {

     }
     if (this.eventChance == 2)
     {

     }
     this.eventCooldown = UnityEngine.Random.Range(50f, 75f);
  }
}
I know I've already created a tutorial on events but in the tutorial all the event code was in the GameControllerScript which can make things really messy. So I decided to convert the things in that tutorial into a custom script where it is much easier to edit. Again like usual please credit me 4 this script if you use it. (Because I'm the owner of this method of events).

Also if you use this script in your decompile then you would put it on the GAMECONTROLLER OBJECT
Sign up to access this!

No comments yet

Embed

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

Credits

Key Authors
RealT5mpler
RealT5mpler Joined 11mo ago
Offline
514 points Ranked 46918th
16 medals 4 rare
  • Returned 1000 times Medal icon
  • 25 posts awarded Exemplary Feedback Medal icon
  • Submitted 15 Tutorials Medal icon
  • 50 posts awarded Exemplary Feedback Medal icon
  • One month a member Medal icon
  • Returned 100 times Medal icon
Creator of Method & Script

Submitter

RealT5mpler avatar
RealT5mpler Joined 11mo ago
Not on right ok
514 points Ranked 46918th
16 medals 4 rare
  • Returned 1000 times Medal icon
  • 25 posts awarded Exemplary Feedback Medal icon
  • Submitted 15 Tutorials Medal icon
  • 50 posts awarded Exemplary Feedback Medal icon
  • One month a member Medal icon
  • Returned 100 times Medal icon
RealT5mpler
Creator
Sign up to access this!
Sign up to access this!
Sign up to access this!

Game

Sign up to access this!

Category

License

Attributes

Language
C#

Share

  • Share on Reddit
  • Share on Twitter
  • Share on Facebook
  • 1
  • 464
  • 2mo
  • 1mo

More from Submitter

WiPs by Submitter

More Other/Misc Scripts