Click to add particle effect on all player parts

i have this script which makes it so a part plays a sound when clicked. now i still want it to make a sound but i also want it to inject a certain particle effect onto all player parts.
already owned things below:

the properties of the certain particle effect:

the script to play sound when clicked:

script.Parent.ClickDetector.MouseClick:Connect(function() 
     script.Parent.woosh.SoundId = "rbxassetid://1839756886"
     script.Parent.woosh:Play()
end)
script.Parent.ClickDetector.MouseClick:Connect(function(plr) 
     script.Parent.woosh.SoundId = "rbxassetid://1839756886"
     script.Parent.woosh:Play()
     for i, v in pairs(plr.Character:GetChildren()) do
         if v:IsA("MeshPart") then
            local particle = script.Parent.ParticleEmitter:Clone()
            particle.Parent = v
            particle.Transparency = 0
         end
     end
end)

This might be it

is there a way to put the particles i made? like that i name the particles or something and then it gets those particles for the script?

I dont understand what u mean (30 characters)

i put the picture of the properties of a particle effect i made, i want that to be the particle effect to be on the players parts. i was thinking it wouldve been easier if i named the particles a certain way to make it easier to script?

Do it however u like it to be, the difference is just in name since ur cloning the ParticleEmitter

so do i change the particleemitter in the script to the name of the particle emitter i made? also what are the locations? the current locations for the sound stuff is already set but idk where to put the particle emitter part.

So in the script I wrote, ParticleEmitter is located inside of that part with click detector and its named “ParticleEmitter”

yes, it works, but only on the lower left arm on the player.

What about this?

script.Parent.ClickDetector.MouseClick:Connect(function(plr) 
     script.Parent.woosh.SoundId = "rbxassetid://1839756886"
     script.Parent.woosh:Play()
     for i, v in pairs(plr.Character:GetChildren()) do
         if v:IsA("MeshPart") or v:IsA("BasePart") then
            local particle = script.Parent.ParticleEmitter:Clone()
            particle.Parent = v
            particle.Transparency = 0
         end
     end
end)

now only on torso, it needs to be on all player parts

If you checked the output, you’d notice that the line particle.Transparency = 0 would error when it inserts it into the torso, so that’s why it only inserts it into the torso. This is because the Transparency property of a ParticleEmitter requires a NumberSequence value, but it is given a number, hence why the error would occur.

It’s better to just toggle the Enabled property of the ParticleEmitter, if it’s disabled at first:

script.Parent.ClickDetector.MouseClick:Connect(function(plr) 
     script.Parent.woosh.SoundId = "rbxassetid://1839756886"
     script.Parent.woosh:Play()
     for i, v in pairs(plr.Character:GetDescendants()) do
         if  v:IsA("BasePart") then
            local particle = script.Parent.ParticleEmitter:Clone()
            particle.Enabled = true
            particle.Parent = v
         end
     end
end)

You can use GetDescendants rather than GetChildren if you want the particles in the accessories too, but if not you can just use GetChildren. The v:IsA("MeshPart") in if v:IsA("MeshPart") or v:IsA("BasePart") then is redundant because a MeshPart is inherited from a BasePart

2 Likes