Instantiate help

Hey,

New here so this has probable been ask 100 times, but I an having in issue with Instantiate, can could use some help.

I created a cube then a prefab which I named “Timtest”
the folder my prefabs in is called…

…Assets/prefab

I build a collider on nother object so that when player hit the object a script will build the prefab. (or a least I’m trying to build that script) That scripted is called “BuildHed” and is below…

var Timtest : GameObject;

function OnTriggerEnter(Other : Collider)
{
if (Other.tag == “Player”)
{
var h : GameObject = Instantiate(Timtest);
}
}

I am getting error on the 7th line,…
The variable Timetest of Timtest of BuildHed has not been assigned.

I do not know why I am getting this error,
Any help would be greatful.

thanks

Check if you’ve assigned the “Timtest” prefab from your Prefabs folder to the “Timtest” variable slot in the Inspector.

Well, If I understand correctly, you have the variable Timtest, a GameObject, and you are trying to instanciate it.

The error you are getting means that the variable is empty (null) when you are calling OnTriggerEnter, and it can’t instanciate it as a result.

As said above, you need to assign a GameObject to this variable, be it via the inspector or via the code.

Duhhhhhh…I am stupid… such a simple thing to overlook

The Script I was making just before this one, I was getting the GameObject by code and when I made this one I overlooked that I had drop the GameObject into the Inspector panel…

Thanks,