I’m trying to create a GUI Text for each player on the scene and then attach a script to the GUI Text that will let the text hover over the players, but when I try to attach the script to it using js I get this error:
Assets/Scripts/hoverNameandObjective.js(11,61): BCE0022: Cannot convert ‘UnityEngine.Component’ to ‘UnityEngine.GameObject’.
My script:
var numberOfPlayers : float;
function Update () {
players = GameObject.FindGameObjectsWithTag("Player");
for (var player : GameObject in players){
var playerInfo=player.GetComponent("playerInfo");
if(playerInfo.sentry == false && playerInfo.screenName == false && this.transform != player.transform ){
playerInfo.screenName = true;
var go = new GameObject("Tesxt", GUIText);
go.AddComponent(GUIText);
go.guiText.text = "bot";
go = gameObject.AddComponent("hoverText");
}
}
}