I have a problem with a little addon that I wrote. It is a deagle that toggles a SloMo by rightclicking.
There are no errors but I want, that when the SloMo is on, the first clip of the deagle loses ammo, but when I use the deagle nothing happens when the SloMo is on, but when I toggle the SloMo of by Rightclicking the deagle loses ammo until the clip is empty.
Can anybody help me? (Sorry I’m new at coding)
This is the relevant code:
function SWEP:Timer() finish = false timer.Create("Timer",0.5,25, function() if self:Clip1() > 0 and finish then self:SetClip1( self:Clip1() - 1 ) elseif self:Clip1() == 0 then finish = true end if self:GetOwner():GetActiveWeapon() ~= "weapon_ttt_slomodeagle" then finish = true end if finish == true then game.SetTimeScale(1) slow = 0 return slow end end) end function SWEP:SecondaryAttack() self:throw_attack() self:Timer() end function SWEP:throw_attack() if slow == 0 then slow = 1 game.SetTimeScale(0.2) elseif slow == 1 then game.SetTimeScale(1) slow = 0 end return slow end