There are several "Static" in my character, but this script can only change one. How can I change everyone?

--(In Workspace/Part/Script)

function Smart(hit)
	local Cloning = game:GetService("ReplicatedStorage").Cloning
	Cloning:FireServer()
	wait(5)
	local Enabled = game:GetService("ReplicatedStorage").Particle
	Enabled:FireServer()
end
script.Parent.SuitUp.MouseClick:Connect(Smart)



--(In ServerScriptService/Script)
local Cloning = game:GetService("ReplicatedStorage").Cloning
local Enabled = game:GetService("ReplicatedStorage").Particle
local particles = game:GetService("Lighting").Static

Cloning.OnServerEvent:Connect(function(hit)
-- Cloning in all body
	            particles:Clone().Parent = hit.Character.UpperTorso
				particles:Clone().Parent = hit.Character.Head
				particles:Clone().Parent = hit.Character.RightUpperArm
				particles:Clone().Parent = hit.Character.LeftUpperArm
				particles:Clone().Parent = hit.Character.LeftUpperLeg
				particles:Clone().Parent = hit.Character.RightUpperLeg
-- They are successfully cloned.
end)

Enabled.OnServerEvent:Connect(function(hit)
	local char = hit.Character
	local cps = char:GetChildren()
		for i, v in pairs(cps) do
			if v.ClassName == 'Part' then
				local pes = v:GetChildren()
				for i, v in pairs(pes) do
					if v:IsA('ParticleEmitter') and v.Name == 'Static' then -- Just want to change the head, the rest of the body does not work.
						v.Enabled = true
					end
				end
			end
		end
end)
-- Head: Enabled
-- Torso: Not Enabled
-- RightUpperArm: Not Enabled
-- LeftUpperArm: Not Enabled
-- LeftUpperLeg: Not Enabled
-- RightUpperLeg: Not Enabled 
-- Do not understand.

4 comments

0

Is all your ParticleEmitter objects Named Static? case sensitive too

0

Sim, nesse processo, ele procura o tipo "ParticleEmitter" com seu nome "Static" e depois de localizar "all Static" espalhados em meu "Character", o script modifica Static.Enabled = false para Static.Enabled = true, mas deve modificar tudo e não modifica apenas um.

0

Well I just tried it in studio and it works fine for me, had a particleemitter named static in my left arm and head and both got enabled, i suggest you use print statements to debug your code

0

Here is the most complete script.