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

Sound Not Playing - A Question for Garry's Mod

Question Answered but Unsolved

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()

return true
end
function SWEP:Think()

end


  • Reverend V92 avatar
    Reverend V92 username pic Joined 11y ago
    Source Engine Expert HL2 Manager HL2:MMod Manager HL2:DM Manager Source Manager OC Manager Syn Manager GMod Manager GMod 9 Manager INS Manager DoD:S Manager CS:S Manager BM Manager L4D Manager L4D2 Manager FNF Manager Moderator
    WAITING
    39,578 points Ranked 110th
    51 medals 3 legendary 13 rare
    • 2019 Top Contributor Medal icon
    • Returned 5000 times Medal icon
    • 10 years a member Medal icon
    • 2nd Place - A Bananite's Guide to... Contest Medal icon
    • 6 years a member Medal icon
    • Returned 1000 times Medal icon
    Reverend V92 avatar
    Reverend V92
    Source Engine Expert
    2mo
    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.
    Friendly Neighborhood Mod avatar
    Mantra
    Friendly Neighborhood Mod
    URL to post:
  • Some_Potassium avatar
    Some_Potassium Joined 4mo ago
    Rotting Away
    192 points Ranked 61,884th
    5 medals 1 legendary
    • Became a Ripe Supporter Medal icon
    • Returned 100 times Medal icon
    • One month a member Medal icon
    • Unlocked Treehouse VIP clearance Medal icon
    • 1 post awarded Exemplary Feedback Medal icon
    2mo
    Cool SWEP idea, but as Reverend V92 avatar said, check for red text (Meaning errors), Got it?
    Banananananananananananananana
    URL to post: