When trying to define the player HumanoidRootPart Position, I'm getting the error code of attempt to index nil with 'Position'
local PathfindingService = game:GetService("PathfindingService")
local enemy = script.Parent
local humanoid = enemy.Humanoid
local Torso = enemy.Torso
for i, v in pairs(game.Workspace:GetChildren())do-- loops through everyone in the game
local human = (v:FindFirstChild("Humanoid"))
local Ntorso = v:FindFirstChild("HumanoidRootPart")
while wait() do
local currentDestination = Ntorso
local startingPosition = Torso.Position
local goalPosition = currentDestination.Position
local path = PathfindingService:FindPathAsync(startingPosition, goalPosition)
local waypoints = path:GetWaypoints()
-- Loop through all of the waypoints in the path
for waypointIndex, waypoint in pairs(waypoints) do
if waypoints.Action == Enum.PathWaypointAction.Jump then
humanoid:ChangeState(Enum.HumanoidStateType.Jumping)
end
local waypointPosition = waypoint.Position
humanoid:MoveTo(waypointPosition)
end
end
end

3 comments
Thanks but when I tried this I wouldn't run the for loop in line 22.
What do you mean?
Try now.