bool TextIsVisible = false; int SightDistance = 100;
OnTick() { vector endDest = Location+lookat*SightDistance; If Trace(Location, endDest) { if (not TextIsVisible) { DamageCharacter() TextIsVisible = true; TextRender.SetVisible(TextIsVisible); } } else { if (TextIsVisible) { TextIsVisible = false; Wait(2 seconds) TextRender.SetVisible(TextIsVisible); } }