# Trace Random number and display in Dynamic text field?

**URL:** <https://forum.kirupa.com/t/trace-random-number-and-display-in-dynamic-text-field/329858>\
**Category:** flash\
**Created:** [October 25, 2012, 4:36pm UTC](https://forum.kirupa.com/t/trace-random-number-and-display-in-dynamic-text-field/329858 "2012-10-25T16:36:22Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Chris\_Lad](https://avatars.discourse-cdn.com/v4/letter/c/eada6e/32.png) [@Chris\_Lad](https://forum.kirupa.com/u/Chris_Lad)\
**Post date:** [October 25, 2012, 4:36pm UTC](https://forum.kirupa.com/t/trace-random-number-and-display-in-dynamic-text-field/329858/1 "2012-10-25T16:36:22Z")

</div>

Iv got it to show what damage is done and it works but it keeps putting the health bar to 0 or less then 0 any idea’s? heres the code without tracing damage that worked fine with the health bar:

```auto
if (this.hitTest(_root.comments.myMovieClipInstanceGAME.Main.Fight.enemy))
        {
            attacked = true;
        
            _root.blood.gotoAndPlay(2);
            _root.comments.myMovieClipInstanceGAME.Main.Fight.hp2.health2-= 10 + Math.ceil(Math.random()*50) ;
            
            
            
        }

```

Damage tracing code:

```auto
if (this.hitTest(_root.comments.myMovieClipInstanceGAME.Main.Fight.enemy))
        {
			attacked = true;
        
            _root.blood.gotoAndPlay(2);
           var H = _root.comments.myMovieClipInstanceGAME.Main.Fight.hp2.health2 -= TR;
			var TR = 10 + Math.ceil(Math.random()*50) ;
			var TR2 = TR;
			_root.comments.myMovieClipInstanceGAME.Main.Fight.rick_mc.At.my_txt.text = TR2;
			
			
        }

```

Thank you In Advance!
