local MPS = game:GetService("MarketplaceService") MPS.ProcessReceipt = function(receiptInfo) if receiptInfo.ProductId == 964670375 then local parts = workspace.Confetti:GetChildren() for i,v in pairs(parts) do for a,b in pairs(v:GetChildren()) do b.Enabled = true wait(10) b.Enabled = false end end return Enum.ProductPurchaseDecision.PurchaseGranted end end
It only enables one of the ParticleEmitter, instead of all the ones inside all the parts. I've used GetDescendants, does the same thing.
Iterate through parts:GetDescendants()
and check if v:IsA("ParticleEmitter")
. If so, v.Enabled = true
. It should solve your problem and eliminate the need for looping twice.
The problem here is you're waiting 10 seconds between each iteration. What you could do to 'fix' that is this (as well as using 1 loop):
local MPS = game:GetService("MarketplaceService") MPS.ProcessReceipt = function(receiptInfo) if receiptInfo.ProductId == 964670375 then local parts = workspace.Confetti:GetDescendants() for i,v in pairs(parts) do if(v:IsA("ParticleEmitter")) then spawn(function() v.Enabled = true wait(10) v.Enabled = false end) end end return Enum.ProductPurchaseDecision.PurchaseGranted end end
If descendants doesn't work, which is most likely will.
I'm going to show you something cool that's an alternative.
local function searchThroughConfetti(parts) for i,v in pairs(parts:GetChildren()) do b.Enabled = true wait(10) b.Enabled = false if v:GetChildren() ~= nil then searchThroughConfetti(v:GetChildren()) end end end MPS.ProcessReceipt = function(receiptInfo) if receiptInfo.ProductId == 964670375 then searchThroughConfetti(workspace.Confetti) return Enum.ProductPurchaseDecision.PurchaseGranted end end
So instead of having two for loops you can call the function again if you need to search the child's children by passing the Child as the new parts. Not sure if this above would work cause I rushed the code but I'm just trying to express the way I go about searching through a childs children. It's just nicer to me to not have two for loops.
The problem was already solved way better than this, but this can also be applied to tables and such.