Change a particles parent from folder to part overtime

I have a round system and am trying to have it so when this function happens, overtime more particles (that are in a folder named extra) get added to the part (being snowEmitter).
But I can’t get it so the particles go in evenly throughout the time of the round. Either they all go in too fast or the round ends with some being left out.

local snowEmitter = nil
local roundTime = 10

function Blizzard()
	local clone = ReplicatedStorage.SnowEmitter:Clone()
	clone.Parent = Workspace
	snowEmitter = clone

	local waitTime = (#clone.extra:GetChildren() / roundTime) / 2

	for _, v in clone.extra:GetChildren() do
		v.Parent = clone
		task.wait(waitTime)
	end
end

You need to calculate the correct interval time based on the number of particles and the total round time. Your current approach divides the total number of particles by the round time, but the / 2 factor seems unnecessary ? It may be causing issues.

You should divide the round time by the number of particles to get the time interval for adding each particle, then use your loop to add each particle with a delay based on the calculated interval.

local snowEmitter = nil
local roundTime = 10

function Blizzard()
	local clone = ReplicatedStorage.SnowEmitter:Clone()
	clone.Parent = Workspace
	snowEmitter = clone

	-- Calculate the wait time between each particle addition
	local numParticles = #clone.extra:GetChildren()
	local waitTime = roundTime / numParticles

	for _, v in ipairs(clone.extra:GetChildren()) do
		v.Parent = clone
		task.wait(waitTime)
	end
end

This works perfectly! Thank you.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.