Why cant I disable particle emitters?

Basically I want to disable particle emitters when a play presses a button, I have this code:

remoteeve.OnServerEvent:Connect(function(player, status, hide)
	if player.Name == script.Parent.Parent.vals.nora.Value then
		if status == 'hide' then
			if hide == true then
				for i, v in pairs(workspace[player.Name]:GetChildren()) do
					if v:IsA("Model") then
						for i, b in pairs(v:GetChildren()) do
							if b:IsA("Part") then
								for i, n in pairs(b:GetChildren()) do
									if n:IsA("ParticleEmitter") then
										if n.Name == "Shadow" then
											n:Destroy()
										end
									end
								end
							end
						end
					end
				end
			end
		end
	end
end)

If I had:

print(n.Name)

it’ll print about 5/7 of the particle emitters, but when I add the n:Destroy() or n.Enabled = false it wont do anything. Please help

2 Likes

You are checking if let’s say the character’s arm is a model not if the player’s character is a model, correct?

1 Like

its a morph, probably shouldve said that. the normal parts for the character are still there by my knowledge, but it just replaces them.

2 Likes

Assuming it is the player’s Character, you can use GetDescendants to directly search for any instance, whether it is a direct child or not.

local nora = script.Parent.Parent.vals.nora
remoteeve.OnServerEvent:Connect(function(player:Player, status, hide)
	local Character = player.Character
	if player.Name == nora.Value and status == 'hide' and hide and Character then
		for _, v in pairs(Character:GetDescendants()) do
			if v:IsA("ParticleEmitter") and v.Name == "Shadow" then
				v:Destroy()
			end
		end
	end
end)
2 Likes

did not know of the :GetDescendants(). thank you

1 Like

also, what does this do? I’ve never seen this before on any of the scripts I’ve looked at so I’m curious

1 Like