Proxillus Posted December 7, 2019 Share Posted December 7, 2019 I've been creating a new weapon and I've got to the point of making custom sounds for it, but basically I want the sound to play when I swing, rather on the impact. I've looked around for ways I could do this and the only one I saw was on an older forum that said to use something like this. local function DoSound(owner) --stuff end local function onequip(inst, owner) --you should have that function already --[...] inst:ListenForEvent("doattack",DoSound,owner) --listen for that event, then do that function, but listen for this guy and not for me end local function onunequip(inst, owner) --you should have that function already --[...] inst:RemoveEventCallback("doattack",DoSound,owner) --undo the listener end I get the idea of it, but i know I'm missing stuff for this to work. Regardless does anyone have an idea on how to just generally create the code for on swing? Link to comment Share on other sites More sharing options...
Proxillus Posted December 10, 2019 Author Share Posted December 10, 2019 Never mind, I went back to this after a while seeing if I could try it again and I figured it out lol. I needed to add an inst to the DoSound(here, owner) rather than just having an owner local function DoSound(inst, owner) inst.SoundEmitter:PlaySound("sound/sound/swing") end local function onequip(inst, owner) inst:ListenForEvent("doattack",DoSound,owner) end local function onunequip(inst, owner) inst:RemoveEventCallback("doattack",DoSound,owner) end Is the code I needed total so it was the same, if anyone else needed some help with it then its here. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.
Please be aware that the content of this thread may be outdated and no longer applicable.