error with simple custom weapon, would like some help

I’ve been trying to make my first weapon(using another as a base and work from), its a simple gun that’s supposed to increase damage in stages as the users health gets lower and play sounds to represent just that.
I did want to refrain from coming here to ask for help (as i believe learning what doesn’t work is as valuable as learning what does work) as i’m still learning and only decided to try and pick up lua recently with no prior coding knowledge.
Just trying stuff until it works has worked out for me until now.

I get this:
[ERROR] addons/test gun/lua/weapons/panicattack/shared.lua:87: ‘then’ expected near ‘=’

  1. unknown - addons/test gun/lua/weapons/panicattack/shared.lua:0

From this:


function SWEP:PrimaryAttack()		
	if ( !self:CanPrimaryAttack() ) then return end		
	local bullet = {}
		bullet.Num = 1				
		bullet.Src = self.Owner:GetShootPos()			
		bullet.Dir = self.Owner:GetAimVector()			
		bullet.Spread = Vector( self.Primary.Cone / 90, self.Primary.Cone / 90, 0 )
		bullet.Tracer = self.Primary.Tracer				
		bullet.Force = self.Primary.Force						
		bullet.AmmoType = self.Primary.Ammo	
			if 
                            ( self.Owner:Health() >= 25 )
				then 
				bullet.Damage = 100
		elseif ( self.Owner:Health() <=  26 and self.Owner:Health() >= 50 )
				then
				bullet.Damage = 40
	    elseif ( self.Owner:Health() <= 51 and self.Owner:Health() >= 75 )
			    then
			   bullet.Damage = 15
		elseif ( self.Owner:Health() <= 76 and self.Owner:Health() >= 100 )
			    then
			   bullet.Damage = 5
		end
	self.Owner:FireBullets( bullet )				
	self.Weapon:SendWeaponAnim( ACT_VM_PRIMARYATTACK )	
	self.Owner:MuzzleFlash()							
	self.Owner:SetAnimation( PLAYER_ATTACK1 )
				if 
					( self.Owner:Health() => 25 )
				then
					self.Weapon:EmitSound("weapons/explode4.wav")
		elseif  
				( self.Owner:Health() <=  26 and self.Owner:Health() >= 50 )
				then
					self.Weapon:EmitSound("weapons/357_fire2.wav")
	    elseif 
				( self.Owner:Health() <= 51 and self.Owner:Health() >= 75 )
			    then
					self.Weapon:EmitSound("weapons/ar2/fire1.wav")
		elseif 
				(	self.Owner:Health() <= 76 and self.Owner:Health() >= 100 )
			    then
					self.Weapon:EmitSound("weapons/crossbow/bolt_fly4.wav")
		end	
	self.Owner:ViewPunch(Angle( -self.Primary.Recoil, 0, 0 ))
	if (self.Primary.TakeAmmoPerBullet) then			
		self:TakePrimaryAmmo(self.Primary.NumShots)
	else
		self:TakePrimaryAmmo(1)
	end
	self:SetNextPrimaryFire( CurTime() + .6 )	
	end

The error itself confuses me “‘then’ expected near ‘=’” as usually i learn something from errors but i don’t understand what this one is referring to. I’ve tried all sorts of things to try to get this to work. So i’d like someone to point out where I’ve gone wrong so i can avoid it in the future. i hope i’m not making a huge fool out of myself and haven’t made a completely unsalvageable mess that resembles lua slightly. thanks in advance!

What line is 87?

lines 80 - 94



			   bullet.Damage = 5
		end
	self.Owner:FireBullets( bullet )				
	self.Weapon:SendWeaponAnim( ACT_VM_PRIMARYATTACK )	
	self.Owner:MuzzleFlash()							
	self.Owner:SetAnimation( PLAYER_ATTACK1 )
				if 
				   (	self.Owner:Health() => 25 ) // line 87
				then
					self.Weapon:EmitSound("weapons/explode4.wav")
		elseif  
				( self.Owner:Health() <=  26 and self.Owner:Health() >= 50 )
				then
					self.Weapon:EmitSound("weapons/357_fire2.wav")
	    elseif 
	

It should be >=, not =>. Also, your elseif-clauses are impossible to reach. For example:


self.Owner:Health() <=  26 and self.Owner:Health() >= 50

Health cannot be below 27 but be above 50.

Oh god i mixed up greater than and less than. Thanks a ton for pointing it out. i knew it’d be something silly like that.

EDIT: after correcting the code by switching the greater than and less than signs the weapon works the way i want it to. Marking the thread as solved now. Thanks again!