How to run a code if a variable is under a number? for example 120 (SOLVED)

i wanted to edit the war battles tutorial but the sprite buffer was filled . So i made an error gui that was visible when the tanks was over 120. but then i wanted to make so i dont was able to make more than 120 tanks. but i just worked with this type of things in phyton and when i tried to make tanks i don’t was able to make any tank! not even one!
Here is my code:

...
elseif action_id == hash("enemy") then
		if tanks > 121 then
			factory.create("#enemycheat")
			tanks = tanks + 1

I got it

You should not use global variables to keep track of things since you run the risk of using it in several places of your code which will cause errors. Instead, store the number of tanks in the `self´ variable so it will belong only to the current script component, like this:

if self.tanks > 121 then
			factory.create("#enemycheat")
			self.tanks = self.tanks + 1

And don’t forget to set it to 0 in init().

1 Like