Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Game Development How to Make a Video Game Score, Enemies, and Game State Monitor Player Health

Tim T. Bigelow-Martin
Tim T. Bigelow-Martin
5,744 Points

Error: The associated script cannot be loaded.

After including the player health script i get this error in the player's inspector https://www.flickr.com/photos/149463286@N08/33024109854/in/shares-0603vP/

It might have something to do with my PlayerHealth script

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PLayerHealth : MonoBehaviour {

    public bool alive;
    [SerializeField]
    private GameObject pickupPrefab;

    // Use this for initialization
    void Start () {
        alive = true;

    }

    void OnTriggerEnter (Collider other) {
        if (other.CompareTag ("Enemy") && alive == true) {
            alive = false;

            // Create the pickup particles
            Instantiate(pickupPrefab, transform.position, Quaternion.identity);
        }
    }
}

Any amount of help would be appreciated.

1 Answer

Looks like you have a little typo in your class name inside the script. The error is likely because the script name and class name must match.