Hitmarker appears on both targets

So I know what my problem is, but after hours of trying to fix it I can’t think of a way to do it. So when I attack the enemy (or target), the GUI is drawn on the target saying the amount of damage. But if I change targets (by clicking on a different enemy) while the hitmarker is still being shown, it then shows on the new target, not the one that actually took the damage. How can I prevent this?

Here is my code:
public void showHitMarker() {
Vector3 v3pos = Vector3.zero;

		if (target) {
			v3pos = target.transform.position;
			v3pos = Camera.main.WorldToScreenPoint(v3pos);
			v3pos.y += 25;
			v3pos.y = Screen.height - v3pos.y;
			v3pos.x -= 25;

		if (showDamage > 0) {
			if (!target)
				showDamage = 0;
			GUI.Label(new Rect(v3pos.x, v3pos.y, 50, 50), damage.ToString(), hitMarker);
			showDamage -= Time.deltaTime;

As you can see, when i switch to a new target it would make sense that it is drawn on the new one. I’ve tried storing the right target to draw it on in a variable but I can’t figure out how to do that properly…

Any ideas?

I would suggest restructuring things a bit. Think about creating a HitDamageScript that you attach to objects when you hit them. The script would render the damage for some time and then destroy itself. You can move the render logic you have now to OnGUI of HitDamageScript. In your hit detection logic add something like:

// assuming target is a GameObject
HitDamageScript script = target.AddComponent<HitDamageScript>();
script.SetDamage(X); // where X is the amount of damage caused

Try setting showDamage = 0 at the point where you change target.