script.Parent.Touched:Connect(function(hit)
if game.Players:FindFirstChild(hit.Parent.Name) or game.Players:FindFirstChild(hit.Parent.Parent.Name) then
script.Parent.CanCollide = false
end
end)
A localscript inside StarterPlayerScripts should do the trick. Just make the part non-collidable locally. The player will be able to go through it, but the NPC should not.