ParticleEmitter won't disable after a specific ammount of time

I have made a code that when a developer product is purchased a ParticleEmitter will enable, but after 8 seconds as specified in the code down bellow with wait(8) they will not disable and I don’t know what the issue is could be if someone knows what the issue may be I’d be very thankful.

local mps = game:GetService('MarketplaceService')
local Part = workspace.Part

local ProductIds = {
	1245491084, -- 5
	1245491700, -- 10
	1245501862, -- 50
	1245501902, -- 100
	1245501989, -- 500
	1245502049, -- 1000
	1245502088, -- 5000
	1245502138, -- 10000
}

game.Players.PlayerAdded:Connect(function(plr)
	mps.PromptProductPurchaseFinished:Connect(function(UserId, productId, Succes)
		for i, v in pairs(ProductIds) do
			if productId == v and Succes == true then
				
				print(plr.Name..' Has succesfully donated!')

				for i, v in pairs(Part:GetChildren()) do
					if v:isA('ParticleEmitter') then

						v.Enabled = true
						wait(8)
						v.Enabled = false

					end
				end

			end
		end
	end)
end)
2 Likes

use :Emit(), its the better option here

1 Like

Seems like the issue was that if there were more particle emitters, it wouldn’t work but if there was only 1 particle emitter it would disable I don’t know why all of them wouldn’t disable.

Because you’re yielding for 8 seconds between each ParticleEmitter being toggled, you need to spawn (create) additional threads of execution such that all of the ParticleEmitters are toggled at once.

task.spawn(function()
	v.Enabled = true
	wait(8)
	v.Enabled = false
end)
1 Like
coroutine.wrap(function()

end)()
1 Like