Is it possible to make a place where a player can hide from my pathfinding NPC and the NPC will go away when the player is in that spot?
Heres the NPC pathfinding script:
game.Players.PlayerAdded:connect(function(player)
player.CharacterAdded:connect(function(cha****racter)
if character then
local function movetonpc()
local vecPoint = workspace.NPC.Humanoid.Position
local closestPlayer, smallestMagnitude = nil,math.huge
for _, player in pairs(game.Players:GetPlayers()) do
local distance = player:DistanceFromCharacter(vecPoint)
if distance < smallestMagnitude then
smallestMagnitude = distance
closestPlayer = player
NPC.Humanoid:MoveTo(player.Character.Humanoid)
end
end
end
while wait(.01) do
movetonpc()
end
end
end)
end)

2 comments
Hey bud, can you indent your lines of code so that it's easier to read? Thanks! :)
?