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)