Checking for several names

Hello, I’m trying to use i,v in pairs to scan through my character and locate 3 specific instances, being 3 particle emitters all with different names, down below is that section of code.

Event.OnServerEvent:Connect(function(Player, Key)
	if Key == "CursedEnergyOff" then
		local Char = Player.Character or Player.CharacterAdded:Wait()
		for i,v in ipairs(Char:GetDescendants()) do 
			if v.Name == "CursedEnergy" then
		end
	end
end)

I’ve got 3 particles, “CursedEnergy”, “Glow”, and “Body”, how could I basically check if anything has one of those 3 names?

Any and all help means the world.

Just making sure I am getting what your saying, you want to check if any of the particle emitters have either the names, “CursedEnergy”, “Glow”, and “Body”?

If that’s the case then do this:

local namesToBeSearched = {"CursedEnergy", "Glow", "Body"}

Event.OnServerEvent:Connect(function(Player, Key)
	if Key == "CursedEnergyOff" then
		local Char = Player.Character or Player.CharacterAdded:Wait()
		for i,v in ipairs(Char:GetDescendants()) do 
			if table.find(namesToBeSearched, v.Name) then --the rest
		end
	end
end)

Explanation on what’s going on:
It will check if the instance’s name is included in the table, namesToBeSearched and if it is then blah blah blah.

1 Like

going to try this right now as we speak, give me 5 minutes

1 Like

This world does not deserve people like you I swear, thank you, this little thing was picking at my brain for a good while now. Thank you for helping me on this, genuinely.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.