Particle module's Set Intensity function is broken for no reason

Once again I am asking for help with my particle module. I have a set intensity function. Simple, right? WRONG. The set intensity function of the module is broken and (mostly) will not function. Here’s my function (cut it out of the module):

function serverEffects.SetIntensity(particle, intensity)
	local amountOfEffects = math.floor(intensity/200)
	local lastEffect = intensity%200
	serverEffects.effect = particle
	if not particle:IsA("ParticleEmitter") then
		serverEffects.effect = particle:FindFirstChildWhichIsA("ParticleEmitter")
	end
	serverEffects.effect.Rate = lastEffect
	for i = 1, amountOfEffects+1 do
		serverEffects.newIntensity = serverEffects.effect:Clone()
		serverEffects.newIntensity.Rate = 200
		print(serverEffects.newIntensity.Parent.Name)
	end
end

I called the function already:

local module = require(script.Parent.ServerEffectsModule)
local test = module.Create("Fire", game.Workspace.Part)
module.SetIntensity(test, 300)

Here’s what I expect to happen. First it gets the amount of extra particle emitters to reach the intensity level (divide by 200), gets the leftover bits (mod), finds the original particle, sets its to the leftover intensity, and starting from 1 to 2 (for loop, 2 is from 1+1 (first one from dividing)), adds more particle emitters and sets them to the max. After I print, it seems like newIntensity does not exist (attempt to index nil with Parent), and as a result, no extra particle emitters are created.
Edit 1: Renamed post to make it clearer
Edit 2: If you know the answer just please help. I’m bumping this up because nobody will reply, just view. Once again another bump, I still need help ya know :frowning:

2 Likes

I believe you forgot to give serverEffects.newIntensity a parent, maybe that is the reason why it’s not working as expected.

Hope this helps, please do reply if the result still differs from your expectations

2 Likes

So cloning would not clone the properties as well? I cloned the main particle emitter in my code

Your solution didn’t work. Just tried it. Got rid of the error though
EDIT: Just dumb, I made it reparent the module instead of the particle emitter.