So basically I have this stretch of code here:
Saber = script.Parent.part
function onKeyPress(inputObject, gameProcessedEvent)
if inputObject.KeyCode == Enum.KeyCode.Q then
if Saber.ParticleEmitter1.Enabled == true then
Saber.ParticleEmitter1.Enabled = false
Saber.ParticleEmitter2.Enabled = false
Saber.ParticleEmitter3.Enabled = false
Saber.ParticleEmitter4.Enabled = false
Saber.SurfaceLight.Enabled = false
Saber.Off:Play()
else
Saber.ParticleEmitter1.Enabled = true
Saber.ParticleEmitter2.Enabled = true
Saber.ParticleEmitter3.Enabled = true
Saber.ParticleEmitter4.Enabled = true
Saber.SurfaceLight.Enabled = true
Saber.On:Play()
end
end
end
game:GetService("UserInputService").InputBegan:connect(onKeyPress)
function Off ()
Saber.Off:Play()
end
script.Parent.Unequipped:connect(Off)
Its a particle emitting light saber, and what its supposed to do is play an on/off sound whenever Q is hit, as Q is the on/off switched assigned, and turn the particles off. The code is almost perfect, however it still plays an on/off when you press Q even when the tool is unequipped/in your backpack. So basically I'm having trouble figuring out how to play the on/off sound when Q is hit ONLY if the tool is equipped.
If any one would be willing to help give me some advice or on what is wrong with the code, then I'll be happy to get that kind of response.
