Unchecked script active? Just wondering how this is working..,

Hi, just really new to scripts.

I was under the impression that if a script was unchecked in the inspector it didn’t run. A funny thing is that my player is going to the spawn point transform only when the script is unchecked. If the script is removed it doesn’t work at all, and if the script is checked it throws up an error.
Hopefully the two screen shots help explain what I mean.

The following code (which someone on one of these forums was kind enough to teach me) is attached to the enemy and when the player collides with them, the player goes to the spawn point.

But only when the code is unchecked.

using UnityEngine;
using System.Collections;

public class Setback : MonoBehaviour {

string TheCollider;

public Transform SpawnPoint, Player, Enemy;

// Use this for initialization
void Start () {
SpawnPoint = GameObject.Find (“SpawnPoint”).transform;
Player = GameObject.Find (“Player”).transform;
}
void OnTriggerEnter (Collider other) {
TheCollider = other.tag;
if (TheCollider == “Player”) {
Player.transform.position = SpawnPoint.transform.position;
}
}

}

To make a long story short, Update wont run if the script is unchecked. Collisions and Triggers will still fire if the checkbox is unchecked and the GameObject is still active in heirarchy. That’s why your player is still able to go to the spawnpoint when that trigger condition is met.

The only reason why you’re getting a null reference error in Start is that GameObject.Find couldn’t find a GameObject with the name SpawnPoint or Player (likely Player since I can’t tell what your entire scene looks like but I do see SpawnPoint), so calling transform on a null instance (or lack of instance I should say) will cause an issue.

OK thanks!
So in this script it doesn’t matter because it only has a void start and no void update, and collisions and triggers will still work.
Thanks. So to avoid the error I need to… Yeah, you’re right, I just renamed the FPC Player in the hierarchy and now there’s no error. I thought the player tag would be enough. Thanks for your help.
All this might seem like a noobish concern, but I’ll leave the thread up in case it helps someone else.