Help!
My NPC keeps walking into a wall.
I have no clue what’s wrong with it.
Here is a script :
local PathfindingService = game:GetService("PathfindingService")
local watsher = script.Parent
local humanoid = watsher.Humanoid
local goal = game.Workspace.Neonblock
local function getpath(destination)
local params = {
["AgentHeight"] = 5,
["AgentRadius"] = 2,
["AgentCanJump"] = false
}
local path = PathfindingService:CreatePath(params)
path:ComputeAsync(watsher.HumanoidRootPart.Position, destination.Position)
return path
end
local function walkTo(destination)
local path = getpath(destination)
for i,v in pairs(path:GetWaypoints()) do
local parte = Instance.new("Part")
parte.Parent = game.Workspace
parte.Material = "Neon"
parte.Anchored = true
parte.CanCollide = false
parte.Position = v.Position
humanoid:MoveTo(v.Position)
humanoid.MoveToFinished:Wait(2)
end
end
while true do
walkTo(goal)
end