Parenting script to a specific NPC

Hi guys,I wanted to make a a part that give a forcefield only to all the NPCs with a specific name,I’m new to scripting so I asked on the forum previously and they told me that I have to Instance a Forcefield and parent it to the NPC.I tried but I’m confused because NPCs are defined humanoids,the same word used also to scripts involving players.Even in the scripts inside of every NPC they are defined humanoids and I didnt have found a way to call a specific NPC.This is the script that I used for the forcefiled,what do I have to do to parent the forcefiled to all the NPCs with that name and not players?

– code
local duration = 10 -- forcefield duration
local blacklist = {}

script.Parent.Touched:Connect(function(part)
	if game:GetService("Players"):FindFirstChild(part.Parent.Name) and not table.find(blacklist, part.Parent.Name) then
		table.insert(blacklist, part.Parent.Name)
		local ff = Instance.new('ForceField')
		ff.Parent = game:GetService("Players"):FindFirstChild(part.Parent.Name).Character
		wait(duration)
		ff:Destroy()
		table.remove(blacklist, table.find(blacklist, part.Parent.Name))
	end
end)
for _,v in pairs(workspace:GetChildren()) do
if v.Name == "Whatever name you want" and v.ClassName == "Model" then
-- // Do code
end
end

Do I have to write this between" local ff" and “wait duration”?

Here:
image

1 Like

Thank you,so I just have to update my script by watching that?,just a question.On line 10 the “(Players)” will not parent the effect also on players or is it just a service or something else?

Players is a service, bruh, :cowboy_hat_face:

1 Like

So the script will give the effect only on the NPC that is walking on it right?

Yes… no, if your finding the Player it will effect the player was indexed

You mean if I put the name of a player in the script it will be indexed to that player?

I don’t know anymore, I’m confused :confused: I just woke up

I will try it and see,so just a last question,in the photo that you sent me,the highlighted line is the place where I have to put the code that you gave me before?

No, just replace all of your code with the one I sent

The one you sent in the photo?