I have a base layout for a particle effect that should be Enabled when I’m holding down a key and should be disabled right after I let go of the key.
However, it isn’t working, and I can’t figure out why.
Here’s the current script:
local userInputService = game:GetService("UserInputService")
local RunService = game:GetService("RunService")
local Fountain = game.Workspace.FountainC.cannon.particleCore.fountain
local UpdateCon
userInputService.InputBegan:Connect(function(input, gameProcessedEvent)
if input.UserInputType ~= Enum.UserInputType.Keyboard then return end
if input.KeyCode ~= Enum.KeyCode.C then return end
if UpdateCon then
UpdateCon:Disconnect()
UpdateCon = nil
end
UpdateCon = RunService.Heartbeat:Connect(function(dt)
Fountain.Enabled = true
end)
end)
userInputService.InputEnded:Connect(function(input, gameProcessedEvent)
if input.UserInputType ~= Enum.UserInputType.Keyboard then return end
if input.KeyCode ~= Enum.KeyCode.C then return end
if not UpdateCon then return end
UpdateCon:Disconnect()
UpdateCon = nil
end)
The “fountain” at the end of the “local Fountain” part is a ParticleEmitter. I’m not sure how to get a particle emitter to enable and disable with a script.
Any help is appreciated!