• Stop a looped sound when player stops using entity
    2 replies, posted
So when you hold 'E' on this entity it plays and sound and gives you armor, for some reason I can't figure out how to make it stop playing the sound when you let go of the 'E' key. Here's the code I have local soundPlayed = false; -- To make sure it doesn't play the sound more than once function ENT:Use(a, c) if self:GetAvailArmour() > 0 then local curArmor = c:Armor(); c:SetArmor(curArmor + 1); self:SetAvailArmour(self:GetAvailArmour() - 1); -- print(self:GetAvailArmour()) if not soundPlayed then self:EmitSound("items/medcharge4.wav", 75); soundPlayed = true; end; end; -- I would assume I put something here because it's the end of the use, wouldn't work though end;
sound.Add and Entity/StopSound Add the "items/medcharge4.wav" with sound.Add, when player stops holding E do ENT:StopSound("name you assigned with sound.Add")
I know how to stop the sound, I don't know when the player stops holding 'E'
Sorry, you need to Log In to post a reply to this thread.