local pfs = game:GetService("PathfindingService")
local path = pfs:CreatePath()
path:ComputeAsync(v.HumanoidRootPart.Position, plrhrp)
local waypoints = path:GetWaypoints()
if waypoints[#waypoints].Position ~= plrhrp then
for some reason position is index nil (this isnt full script)
i cant find any solution
ok so im trying to make the script follow the person i say so plrhrp is the person’s humanoidrootpart of who i say also the nil part is the position after i get the last waypoint and idk why
game.Players.GreySkiesofSpace.Chatted:Connect(function(msg)
local String = msg
local split = string.split(String, " ")
if split[1] == "follow" then
while wait() do
if split[2] == "me" then split[2] = "GreySkiesofSpace" end
if game.Players:FindFirstChild(split[2]).Character.HumanoidRootPart ~= nil then
local plrhrp = game.Players:FindFirstChild(split[2]).Character.HumanoidRootPart.Position
if waypoints[#waypoints].Position ~= plrhrp then
path = pfs:CreatePath()
path:ComputeAsync(v.HumanoidRootPart.Position, plrhrp)
waypoints = path:GetWaypoints()
end
this is the full part of the statement
it might be the cause
also i tried that but it unreliable and it hardly updates the loop xd probably because i dont use .movetofinished because it makes the npcs pathfind one at a time
for p,o in pairs(waypoints) do
if v:FindFirstChild("Enemy") ~= nil then
v.Enemy:MoveTo(o.Position)
if o.Action == Enum.PathWaypointAction.Jump then
v.Enemy.Jump = true
end
end
end