I am making a game that once a button is clicked a serious of lanterns are released around the game. My code runs fine, except for when i add the "wait(40)" you see at line 15.
When the wait is there only ONE lantern is released.
I tested my code without the wait and it runs perfectly.
Here is my code:
local light = script.Parent.LIGHT
script.Parent.ClickDetector.MouseClick:connect(function()
script.Parent.Transparency = 1
local la = game.Workspace.Lanterns
local lag = la:GetChildren()
for _,v in pairs (lag) do
if v.Name == "LanternAtt" then
local attA = v:FindFirstChild("AttachmentA")
if attA then
local at = attA:FindFirstChild("Attachment")
if at then
light:Play()
at:Destroy()
wait(40)
game.Workspace.Atmosphere.ParticleEmitter.Enabled = false
end
end
end
end
wait(100)
for _,v in pairs (lag) do
v:Destroy()
end
end)
If anyone could help that would be amazing! Thanks,
