Why is this code not working?

I’m following a tutorial

public Transform player;

why is this line in my start giving me an error?

player = GameObject.FindWithTag (“Player”);

Because GameObject.FindWithTag ("Player"); returns a GameObject, but your player variable is of type Transform.

A GameObject is not a Transform.

But a GameObject has a transform property. So maybe you wanted to do this?player = GameObject.FindWithTag("Player").transform;

thats weird, its working in the tutorial which is only from Aug 2017

but cool, will give that a go.

Thanks Paetor!!!

It didn’t work in your tutorial either. If you watch further into the video he runs into the exact error you ran into and explains it (timestamp 19:55 or so)

1 Like

Sorry it did give an error, his intelisense wasnt showing untill he ran it 6 min later, sorry!!!

Just saw it now, hey have you made any games i can check out?