weird result when substracting/adding;

I have a problem…I have a very simple script that should substract or add one variable from another every update but it always substracts only once:

#pragma strict

var num : int;
var dmg : int;

function Start () {


function Update () 

	num = 5;
 	dmg = 1;
	num = num - dmg;


I simply substrack two integers one from another snd print the result in the console…in this case it shoud give me 4, 3, 2, and so on but it always stops at 4 and if I try to add the two integers it stops at 6.

The Update function is called every frame. Inside that function you’re setting num to 5 and dmg to 1, then subtracting. So each time through the code - i.e. every time Update is called - you’ll see 4 in the log.

You need to initialize your variables in the Start function. Move your num = 5 and dmg = 1 code to Start.