Broken If Statement

I have a zombie survival server with a bunch of custom weapons, and i’ve noticed an extremely weird problem with one of the weapons in particular. Basically, the point of the weapon is that every time you shoot there’s a 1 / 15 chance that you will do 1000 damage, I did this using math.random and if statements, and it seems to work fine, however it’s supposed to play a special sound whenever you do the 1000 damage shot, and it does this, but for whatever reason it will also sometimes play this sound even if you don’t get 1000 damage, and I have no idea how considering the only time the sound is played is in this if statement, so how could it be playing the sound, which is one part of the if statement, without doing the 1000 damage? Why is it only doing half of the stuff in the if statement?


AddCSLuaFile()

if CLIENT then
	SWEP.PrintName = "blah blah"
	SWEP.Description = "A gun."
	SWEP.Slot = 3
	SWEP.SlotPos = 0
        SWEP.ViewModelFOV = 60

end

SWEP.Base = "weapon_zs_base"

SWEP.HoldType = "ar2"

SWEP.ViewModel = "models/weapons/cstrike/c_snip_scout.mdl"
SWEP.WorldModel = "models/weapons/w_snip_awp.mdl"
SWEP.UseHands = true

SWEP.ReloadSound = Sound("Weapon_Scout.ClipOut")
SWEP.Primary.Sound = Sound("zombiesurvival/jumper1.ogg")
SWEP.Primary.Damage = 1
SWEP.Primary.NumShots = 1
SWEP.Primary.Delay = .25
SWEP.ReloadDelay = SWEP.Primary.Delay

SWEP.Primary.ClipSize = 1
SWEP.Primary.Automatic = true
SWEP.Primary.Ammo = "357"
SWEP.Primary.DefaultClip = 1

SWEP.Primary.Gesture = ACT_HL2MP_GESTURE_RANGE_ATTACK_CROSSBOW
SWEP.ReloadGesture = ACT_HL2MP_GESTURE_RELOAD_SHOTGUN

SWEP.ConeMax = 0.08
SWEP.ConeMin = 0.015

SWEP.IronSightsPos = Vector(-4, 2, 1)
SWEP.IronSightsAng = Vector(0, 0, 0)

SWEP.WalkSpeed = SPEED_SLOW

function SWEP:PrimaryAttack()
if not self:CanPrimaryAttack() then return end
self:SetNextPrimaryFire(CurTime() + 1)

local dmg = math.random( 1, 15 )

        if dmg ~= 7 then
	       self:ShootBullets(1, 1, self:GetCone())
	       self.IdleAnimation = CurTime() + self:SequenceDuration()
	       self:EmitFireSound()
        end


        if dmg == 7 then
               local owner = self.Owner
               owner:EmitSound("zombiesurvival/heavyfire.ogg")
               self:ShootBullets(1000, 1, self:GetCone())
        end


	
end	

A few things I already tried was putting the self:ShootBullets before the sound, and having it be self:EmitSound instead of owner:EmitSound, neither of those changed anything.
Also while I was trying to figure out what was wrong with it I put a print after local dmg and for whatever reason it would come up with 3-5 numbers at a time instead of the predicted one, so I think that might be what the problem is, but it’s still weird how it can play the sound without doing the 1000 damage.

[editline]1st September 2016[/editline]

Also, if any of you need the weapon_zs_base this is derived from you can find it here :

Use a networked variable instead. The issue is that the client gets 7 but the server doesn’t (or vice versa), resulting in the sound being heard even if it doesn’t do 1000 damage.

I didn’t know what you meant by networked variables however I tried putting an if SERVER then in the if statement for the 1000 damage and that seemed to fix it. Thanks for the help.