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:
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)
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?
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.
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)
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