Invalid expression terms on getComponent

So I’m beginning to make a simple script for the title of a game so that when you start the game the a script starts in sync with the music, I thought I should do it in seconds to make it easier and when i just delete the error, errors appear on the seconds part that has nothing to do with the getComponent part.

public class MusicStart : MonoBehaviour {
	public int BPM = 0;
	private bool Activated = false;
	public string Script;
	public bool Beat = false;
	public float secondsBetweenBeats = 0.00f;

	// Use this for initialization
	void Start () {
	// Update is called once per frame
	void Update () {
		// Divide 60 by the BPM so that the beats happen every so many seconds depending on the beat
		// Every time there is a beat the bool shoul go true then false after just because it looks cool
		// * is multiply / is divide
		// jesus christ this is confusing
				secondsBetweenBeats == 60 / "BPM";
		if ((Activated) == true)
			GetComponent<"Script">().enabled = true;

A couple of things to note:

You should use Time.deltaTime to make things framerate independent.

When using GetComponent, you do not need to put the name of the type in quotes. Just the type name. For example:

GetComponent<MeshFilter> ().enabled = true;

The answer here is to **do more beginner tutorials **

What I would do is create a TitleScreenManager to draw whatever elements I want to the screen.

If your event is timed, then utilize a timed method call with either:

A Coroutine

  void Start() { 
        // begin after 4 seconds

          IEnumerator ExecuteAfterTime(float time) {
                yield return new WaitForSeconds(time);
                //Do game title stuff here!

Or easier to understand for a beginner, an Invoke method:

 void Start() {
        // call method after 2 seconds...
        Invoke("CallNow", 2);

    void CallNow() {
        //do game title stuff here!

Or if you are calling a method dependent on a beat, then try

// call method after 4 seconds, then call the method every 2 seconds
InvokeRepeating("CallMethod", 4, 2);

I don’t think it is necessary to enable or disable scripts when you can just call a Method when you need it.

However, if you HAVE to do it, then the proper way to enable a script is to reference the script as a variable/class type, not a string.

GetComponent<scriptName>().enabled = true;

The above only works if you have the script on the same gameObject. If the script is on another gameObject you will have to [Serialize] a reference that gameObject, then call the disable on the script.

Good luck :wink: