I need help switching a script of mine, so instead of pressing a key to enable and disable a particle, pressing the mouse and releasing it is how it should function.
local userInputService = game:GetService("UserInputService")
local particles = workspace.LightningC.cannon.particleCore
function emit()
for number,index in pairs(particles:GetChildren()) do
if index:IsA("ParticleEmitter") then
index.Enabled = not index.Enabled
end
end
end
userInputService.InputBegan:Connect(function(input, gp)
if gp then return end
if input.KeyCode == Enum.KeyCode.C then
emit()
end
end)
userInputService.InputEnded:Connect(function(input, gp)
if gp then return end
if input.KeyCode == Enum.KeyCode.C then
emit()
end
end)
Any help is appreciated!