Ads keep us online. Without them, we wouldn't exist. We don't have
paywalls or sell mods - we never will. But every month we have large bills
and running ads is our only way to cover them. Please consider unblocking us. Thank you from GameBanana <3
This Question has been answered but no solution has been chosen.
You can still post your own answer to help the submitter.
The first sound plays but the second one doesn't
I'm trying to make a SWEP that creates an explosion with custom sound and kills you but somewhy, the first sound works but the explosion one doesn't. Please help, I've been hitting my head for two weeks just to figure this problem out. Here's the code
AddCSLuaFile() SWEP.PrintName = "Skibidi bop mm dada" SWEP.Author = "hyperix" SWEP.Purpose = "Get Real" SWEP.Spawnable = true SWEP.AdminSpawnable = true SWEP.AdminOnly = true SWEP.UseHands = false SWEP.DrawAmmo = false SWEP.ViewModel = "" SWEP.WorldModel = "" SWEP.TraceLength = 500 SWEP.ViewModelFOV = 52 SWEP.Slot = 0 SWEP.SlotPos = 5 SWEP.Effect = "c4_explosion" SWEP.EffectAir = "c4_explosion_air" util.PrecacheModel( SWEP.ViewModel ) SWEP.Primary.ClipSize = -1 SWEP.Primary.DefaultClip = -1 SWEP.Primary.Automatic = false SWEP.Primary.Ammo = "none" SWEP.Secondary.ClipSize = -1 SWEP.Secondary.DefaultClip = -1 SWEP.Secondary.Automatic = false SWEP.Secondary.Ammo = "none" local Explosion = { "REKT.mp3" } local Troll = { "dead.mp3" } SWEP.DamageDistance = 1000 function SWEP:Initialize() self:SetHoldType( "normal" ) self.CanPerformAttack = true timer.Simple(0.05,function() end) end function SWEP:PreDrawViewModel( vm, wep, ply ) --vm:SetMaterial( "engine/occlusionproxy" ) end if CLIENT then SWEP.WepSelectIcon = surface.GetTextureID( "vgui/troll" ) end function SWEP:PrimaryAttack( right ) if not self.CanPerformAttack then return false end self.CanPerformAttack = false self.Owner:SetAnimation(ACT_VICTORY_DANCE) local vm = self.Owner:GetViewModel() --vm:SendViewModelMatchingSequence( vm:LookupSequence( anim ) ) self:EmitSound( Sound( "dead.mp3" )) --sound.Play(Troll[math.floor(math.Rand(1,3))] , self:GetPos(), 180 , 100, 1 ) timer.Simple(1,function() self:EmitSound( Sound( "REKT.mp3" )) local pos = self.Owner:GetPos() local tracedata = {} tracedata.start = pos tracedata.endpos = tracedata.start - Vector(0, 0, self.TraceLength) tracedata.filter = self.Entity local trace = util.TraceLine(tracedata) if trace.HitWorld then ParticleEffect(self.Effect,pos,Angle(0,0,0),nil) else ParticleEffect(self.EffectAir,pos,Angle(0,0,0),nil) end if CLIENT then self:EmitSound( Sound( "REKT.mp3" )) sound.Play( self:GetPos(), 180 , 100, 1 ) elseif SERVER then util.BlastDamage(self, self.Owner, pos, self.DamageDistance, 250) for k,v in pairs(ents.FindInSphere(self:GetPos(),1024)) do if v and v:IsValid() then if not type(v) == "prop_physics" then return false end constraint.RemoveConstraints( v, "Weld" ) local phys = v:GetPhysicsObject() if phys and phys:IsValid() then phys:Wake() phys:EnableMotion(true) phys:ApplyForceCenter(-(self:GetPos()-phys:GetPos()) * (phys:GetMass()*(1024-phys:GetPos():Distance(self:GetPos())) ) ) end end end end end) end function SWEP:SecondaryAttack() end function SWEP:OnRemove()
if ( IsValid( self.Owner ) && CLIENT && self.Owner:IsPlayer() ) then local vm = self.Owner:GetViewModel() if ( IsValid( vm ) ) then vm:SetMaterial( "" ) end end
end function SWEP:Holster( wep ) self:OnRemove() return true end function SWEP:Deploy()
Your sound path is incorrect. Check the console for some red text about a missing sound. self:EmitSound( Sound( "REKT.mp3" )) won't work unless rekt.mp3 is in sound/ directly.