-- Inflation Gun SWEP if SERVER then AddCSLuaFile() -- Ensure the client-side portion is sent to the client end SWEP.PrintName = "Inflation Gun" SWEP.Author = "YourName" SWEP.Instructions = "Shoots inflation effects on NPCs" SWEP.Spawnable = true SWEP.AdminOnly = false -- Set this to true if you only want admins to use it SWEP.Category = "Inflation Guns" -- This puts the weapon under the "Inflation Guns" category in the spawn menu -- Primary fire attributes SWEP.Primary = { Ammo = "none", -- No ammo required for this weapon Damage = 0, -- No direct damage (the effect is the "damage") Automatic = false, -- It's a semi-automatic weapon ClipSize = -1, -- Infinite ammo } -- Secondary fire attributes (optional) SWEP.Secondary = { Ammo = "none", Damage = 0, Automatic = false, ClipSize = -1, } -- List of random sounds to play during inflation local randomSounds = { "npc/strider/creak1.wav", "npc/strider/creak2.wav", "npc/strider/creak3.wav", "npc/strider/creak4.wav", "npc/strider/strider_legstretch1.wav", "npc/strider/strider_legstretch2.wav", "npc/strider/strider_legstretch3.wav" } -- List of bones to affect (same as in your original script) local bodyBones = { "ValveBiped.Bip01_Pelvis", "ValveBiped.Bip01_Spine", "ValveBiped.Bip01_Spine1", "ValveBiped.Bip01_Spine2", "ValveBiped.Bip01_Spine3", "ValveBiped.Bip01_Spine4", "ValveBiped.Bip01_L_Clavicle", -- Left Clavicle "ValveBiped.Bip01_R_Clavicle", -- Right Clavicle "ValveBiped.Bip01_L_UpperArm", "ValveBiped.Bip01_R_UpperArm", "ValveBiped.Bip01_L_Thigh", "ValveBiped.Bip01_R_Thigh", "ValveBiped.Bip01_L_Calf", "ValveBiped.Bip01_R_Calf", "ValveBiped.Bip01_Neck1" } -- Initialize the inflation data when the NPC is hit for the first time function SWEP:PrimaryAttack() local tr = self.Owner:GetEyeTrace() local hitEntity = tr.Entity -- Check if it hit an NPC if IsValid(hitEntity) and hitEntity:IsNPC() then -- Initialize inflation data if not already initialized if not hitEntity.InflateData then hitEntity.InflateData = {} for _, bone in ipairs(bodyBones) do -- Set initial spine size to 1, while other bones can remain at 1 hitEntity.InflateData[bone] = { size = 1, inflateRate = 0.0025, inflateFactorYandZ = 1.03 } -- Slower inflation rate and smaller Y/Z inflation factor end end -- Start automatic inflation after the first shot if not hitEntity.Inflating then hitEntity.Inflating = true -- Set a smooth inflation timer with slower updates timer.Create("InflateTimer_" .. hitEntity:EntIndex(), 0.1, 0, function() -- Slower updates (0.1 seconds) if not IsValid(hitEntity) then timer.Remove("InflateTimer_" .. hitEntity:EntIndex()) return end -- Apply smooth inflation using Lerp for _, bone in ipairs(bodyBones) do local boneData = hitEntity.InflateData[bone] -- Smoothly increase the size of the bone using Lerp with a smaller increment boneData.size = Lerp(0.1, boneData.size, boneData.size + boneData.inflateRate) -- Apply different inflation behavior for the clavicles (X-axis) if bone == "ValveBiped.Bip01_L_Clavicle" or bone == "ValveBiped.Bip01_R_Clavicle" then -- Apply inflation along the X-axis for clavicles boneData.inflateFactorYandZ = 1 -- No Y/Z expansion for clavicles else -- Increase the Y and Z axis scaling factor at a smaller rate for other bones boneData.inflateFactorYandZ = boneData.inflateFactorYandZ + 0.005 -- Slower Y/Z inflation end -- Adjust the inflation rate to make the process smoother and still slower boneData.inflateRate = math.max(boneData.size * 0.02, 0.0025) -- Slower inflation rate -- Apply scale to the bone, using the inflation factors local boneIndex = hitEntity:LookupBone(bone) if boneIndex then -- Apply X scaling for clavicles and Y/Z scaling for other bones local scale if bone == "ValveBiped.Bip01_L_Clavicle" or bone == "ValveBiped.Bip01_R_Clavicle" or bone == "ValveBiped.Bip01_Pelvis" then scale = Vector(boneData.size * boneData.inflateFactorYandZ, boneData.size, boneData.size * boneData.inflateFactorYandZ) -- Smaller X expansion for clavicles else scale = Vector(boneData.size, boneData.size * boneData.inflateFactorYandZ, boneData.size * boneData.inflateFactorYandZ) -- Slower Y/Z expand end hitEntity:ManipulateBoneScale(boneIndex, scale) -- Apply the scaled bone end end -- Delay the sound effects if not hitEntity.LastSoundTime then hitEntity.LastSoundTime = CurTime() -- Initialize if not set end -- Define a delay between sounds (in seconds) local soundDelay = 0.5 -- Delay between sound effects in seconds -- Check if enough time has passed to play a new sound if CurTime() - hitEntity.LastSoundTime >= soundDelay then -- Randomly choose a sound from the list to play local randomSound = randomSounds[math.random(#randomSounds)] -- Play the random sound, with pitch adjusted based on size for variation hitEntity:EmitSound(randomSound, 75, 100 + (hitEntity.InflateData["ValveBiped.Bip01_Spine"].size * 10)) -- Update the time of the last sound played hitEntity.LastSoundTime = CurTime() end -- Check if the NPC's spine size has reached a threshold local spineData = hitEntity.InflateData["ValveBiped.Bip01_Spine"] -- Log the current size of the spine print("Current Spine Size: " .. spineData.size) -- Debugging log -- Check for explosion when the spine size reaches a threshold if spineData.size >= 2 then -- Explode the NPC hitEntity:TakeDamage(hitEntity:Health()) -- Make it explode visually local effect = EffectData() effect:SetOrigin(hitEntity:GetPos()) util.Effect("Explosion", effect) hitEntity:Remove() -- Remove the NPC after explosion timer.Remove("InflateTimer_" .. hitEntity:EntIndex()) -- Stop inflation timer end end) end -- Reset the weapon attack (no cooldown required) self:SetNextPrimaryFire(CurTime() + 1) end end -- Weapon HUD (if needed for basic information) if CLIENT then function SWEP:DrawHUD() -- You can add any visual HUD elements here if desired end end