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

How to clone particles into character of localplayer?

I am trying to clone 4 particles into each part of the player's body. I am using R15. I tried using a in pairs loop to clone them.





part1 = script.aura:Clone() --variables
part2 = script.aura2:Clone()
part3 = script.aura3:Clone()
part4 = script.small:Clone()


function addparticle() --function
	print("function activated")
	for i,v in pairs(char:GetChildren()) do
		print("did i,v") -- printed in the output 27 times?
		if v:IsA('Part') or v:IsA('MeshPart') then
			part1.Parent = v 
			part2.Parent = v
			part3.Parent = v
			part4.Parent = v
		end
		end
end

This works. But the particles are only cloned in the left leg somewhere and that's it. Anyone know what's wrong?

Edit: This is a localscript.

1 answer

✓ Accepted answer

Perhaps this code would work? A for loop instead of an in pairs loop.

local CharGet = char:GetChildren

function addparticle() --function
    print("function activated")
   	 for i = 1, #CharGet do
   	 print("did", i)

if CharGet[i]:IsA('Part') or CharGet[i]:IsA('MeshPart') then

            part1.Parent = CharGet[i] 

            part2.Parent = CharGet[i] 

            part3.Parent = CharGet[i] 

            part4.Parent = CharGet[i] 

        	end
        end
end

3 comments

0

Same thing happened. Particles were only cloned to the right leg.

0

That is... Odd, to say the least. Also, I have some unfortunate news for you. If your game has filtering enabled, the above script will do nothing for other players unless it's in a script rather than a localscript.

0

Wasn't a localscript. Someone on the discord figured it out. Move part1, part2, etc. into the for i,v loop.

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