Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why Won't this GetChildren() and Clone() work?

Hey! So now I am attempting to make a Bloom Effect using custom particles. Basically what I'm trying to do is make the ParticleEmitter to be cloned into every part in the Workspace but this isn't working. I am using a :GetChildren to get all the parts in the workspace (Obviously) and using Clone() to cloen the emitter in one block to put it in all the parts.

A = game.Workspace:GetChildren()
Emit = game.Workspace.Emitter.Particle:Clone()

for i,v in pairs(A) do
if v.className == "Part" then
Emit.Parent = v
end
end

Nothing is in the output again so I don't know what to do or what is wrong. Thanks! ~Minikitkat

2 answers

✓ Accepted answer

Just put the cloning line in the loop like this

A = game.Workspace:GetChildren()

for i,v in pairs(A) do
if v.className == "Part" then
Emit = game.Workspace.Emitter.Particle:Clone()
Emit.Parent = v
end
end

2 comments

0

Oh, That simple? Interesting. Thanks!

1

Oh, and put local Emit instead of just Emit, since it's in a scope.

I see what you're trying to do, but most of the time, shortcuts don't work like that.

You need to clone the emitter in the for loop and then set it's parent to the part. I would also recommend you "tab out" your code as it looks a lot cleaner.

A = game.Workspace:GetChildren()
Emit = game.Workspace.Emitter.Particle

for i,v in pairs(A) do
	if v.className == "Part" then
		local e = Emit:Clone() --We now clone the emitter every time a part is detected.
		e.Parent = v --Set the clone's parent to the part.
	end
end

However, that will only work for parts. What about wedge parts and unions? You can use IsA for the wedge parts to check if the part is a BasePart. You can also add in another condition using and for the Union Operations.

A = game.Workspace:GetChildren()
Emit = game.Workspace.Emitter.Particle

for i,v in pairs(A) do
	if v:IsA("BasePart") or v:IsA("UnionOperation") then --Checks if the part is a part or a union.
		local e = Emit:Clone() --We now clone the emitter every time a part is detected.
		e.Parent = v --Set the clone's parent to the part.
	end
end

2 comments

1

Ninja'd. Sorry, funy. :)

0

s'ok mang

This discussion is preserved as it was. New answers, comments, and votes are closed.