• Trying to make custom gun firing sound with the pistol world model
    5 replies, posted
I'm pretty new to lua but I have some idea on how to code with it. I am trying to make a custom gun firing noise that works with any weapon that uses the models/weapons/w_Pistol.mdl world model. I tried testing it and as i suspected it didn't work. This is the code local noise = Sound("jwpistolshot.wav") if Entity:GetModel(models/weapons/w_Pistol.mdl) then Swep.Primary.Sound = Sound( noise )
Swep needs to be SWEP GetModel doesn’t have any arguments Where on earth are you running this code? This won’t work with the default HL2 Pistol because it isn’t an SWEP(?) You never end your if statement
have fun..
local noise = Sound("jwpistolshot.wav") if SWEP.WorldModel == "models/weapons/w_pistol.mdl" end then SWEP.Primary.Sound = Sound( noise ) this is the code now im running it from GarrysMod\garrysmod\lua\autorun
Is this the full code? SWEP isn't a valid table in lua/autorun files.
Yes and i did not know that i figured i could put it into autorun and not have to manually load it
Sorry, you need to Log In to post a reply to this thread.