My problem with level script

Hello,
I have made level script but im having problems.
In my enemy script there is variable
var playerLevel : LevelSystem;
because when enemy die it gives me points ‘exp’
but in inspector i have to drag and drop something there i know it should be player with attached LevelSystem script, thats what i do but when i attach the player from hierarchy it works perfect, but when i want to attach the prefab of player it doesnt work, it doesnt lvl up it just collect ‘exp’ but doesnt change the lvl and also it stores the ‘exp’ in the player prefab :frowning: I hope you understand what i mean
because it works perfect when i drag and drop the ‘player’ from hierarchy to the enemy in hierarchy but i cant drag and drop the player from hierarchy into enemy prefab, because im spawning ‘waves’ and for this i need to drag and drop enemy prefab with this level system but i cant :frowning:

Thanks for helping!!

Try using “GameObject.Find”.
Since you can’t assign gameObjects from the hierarchy to prefabs, you’ll have to assign the variables at runtime :

function Start(){
playerLevel = GameObject.Find("LevelSystem");
}

I have tried that and iam having this error
Assets/Scripts/Enemy.js(24,38): BCE0022: Cannot convert ‘UnityEngine.GameObject’ to ‘LevelSystem’.

Also i dont know why but i have also ‘Point’ system and it works good with the player prefab but the level doesnt work with player prefab, on prefab of player it doesnt reset the ‘exp’ and doesnt change the level if its over 100

i have looked at my point script for like 5 min and change something and check in game and again and again and i got it
i have change the var of my exp from
var exp : int;
to
static var exp : int = 0;
and it works now :smile: