Find Object with variable, not a name.

Hi guys, this might be confusing so i’ll just write up an example.

Ability1 = Player.Getcomponent("Monster")

How would i replace (“Monster”) with (Monster)

So, instead of defining a single script, i can make it a variable which can be changed whenever. e.g., var Monster = "Monster1";

Thanks

string myType = “Monster”;
Ability1 = Player.GetComponent(myType);
myType = “Somethingelsethanmonster”;
Ability1 = Player.GetComponent(myType);

Does this work for you ?