function InstaCooldown40( _, activator, caller ) local userSecondaryWeapon = activator:GetPlayerItemBySlot(1) local useCost = userSecondaryWeapon:GetAttributeValue("mod ammo per shot") or 1 activator.cooldown = 40 local i = 0 activator.InstaCooldownTimer = timer.Create(0.05, function () -- activator:AcceptInput("$DisplayTextChat", "{blue}Timer working.") if IsValid(activator:GetPlayerItemBySlot(1)) and activator:IsValid() then local userSecondaryWeaponTemp = activator:GetPlayerItemBySlot(1) if userSecondaryWeapon ~= userSecondaryWeaponTemp then timer.Stop(activator.InstaCooldownTimer) -- activator:AcceptInput("$DisplayTextChat", "{red}Your Secondary is wrong, stopping.") return end else timer.Stop(activator.InstaCooldownTimer) -- activator:AcceptInput("$DisplayTextChat", "{red}You have no Secondary, stopping.") return end if (activator.cooldown <= 0 or not activator:IsAlive()) and activator:IsValid() then timer.Stop(activator.InstaCooldownTimer) userSecondaryWeapon:SetAttributeValue("mod ammo per shot", useCost) -- activator:AcceptInput("$DisplayTextChat", "{green}Cooldown over, returning the ammo cost") activator:AcceptInput("$DisplayTextCenter", "Secondary Ready", activator) return end activator:AcceptInput("$DisplayTextCenter", "Cooldown: "..activator.cooldown.."s", activator) userSecondaryWeapon:SetAttributeValue("mod ammo per shot", 99999) i = i + 1 if i >= 20 then activator.cooldown = activator.cooldown - 1 i = 0 end end, 0) end