Okay so I built this cannon and I'm doing some testing, I'm experimenting with muzzle flash. so this is the script for a button to "fire" the cannon, well more to check muzzle flash, screen shake, and sound.
What I'm having trouble with is that I'm trying to get the particles to be disabled after a certain time, I tried using wait() but it just broke the thing entirely.
I've been told to use a coroutine, I've attempted to do so but was not successful.
any help is appreciated
local ClickDetector = workspace.Part.ClickDetector
local button = script.Parent
local sound = game.Workspace:FindFirstChild("410mm")
function fire()
sound:Play()
sound.Looped = false
local gun = game.Workspace:FindFirstChild("WEEBLYIOWA")
local descendants = gun:GetDescendants()
for _, v in pairs(descendants) do
if v:IsA("ParticleEmitter") then
v.Enabled = true
end
wait(4)
v.Enabled = false
end
end
ClickDetector.MouseClick:connect(fire)

1 comment
I posted the exact answer to my question an hour prior to this one, however I can't get my own answer to label the question as answered. I'll highlight this reply to help others. thanks