score not going up when i kill an enemy

i’m trying to make a score text that goes up whenever the player kills an enemy but the text wont update from zero

i have created a public text in an enemy prefab and as text i’ve also used a prefab

and here is my script

i’ve conducted some tests and figured out that the float enemieskilled does update

If the counter is working, then the problem is clearly with the text updating. The only solution I can think of with the given information is to make sure you are setting the KillCounter text to the instance of the text in the scene and not to the prefab itself.

On a side note, I noticed that you are repeatedly setting the text to the score in Update(), which is not performant. I would only update the text immediately after you change the value of the EnemiesKilled variable:

EnemiesKilled += 1;
KillCounter.text = EnemiesKilled.ToString();

This is of course not going to solve the issue but it is something to keep in mind of in the future.