local PFS = game:GetService('PathfindingService')
local R6 = game.Workspace.R6
local Humanoid = R6.Humanoid
local EndPoint = workspace.EndPoint
local Path = PFS:CreatePath()
Path:ComputeAsync(R6.HumanoidRootPart, EndPoint)
if Path.Status == Enum.PathStatus.Success then
local nodes = Path:GetWaypoints()
for i, v in pairs(nodes) do
local node = Instance.new('Part')
node.Size = Vector3.new(1,1,1)
node.Position = v.Position
node.Anchored = true
node.CanCollide = false
if v.Action == Enum.PathWaypointAction.Jump then
Humanoid.Jump = true
end
Humanoid:MoveTo(v.Position)
Humanoid.MoveToFinished:Wait(1)
end
end
So I don’t know why this isn’t working seeing as there are no errors. The script is located in ServerScriptService, I’ve tried unanchoring the dummy but he still doesn’t move. The node part that’s supposed to show where the dummy is going to go next doesn’t work either.
--//Services
local PFS = game:GetService("PathfindingService")
--//Variables
local R6 = workspace.R6
local Humanoid = R6.Humanoid
local EndPoint = workspace.EndPoint
--//Initialization
task.wait(2)
local Path = PFS:CreatePath()
Path:ComputeAsync(R6.HumanoidRootPart, EndPoint)
print(Path.Status)
if Path.Status == Enum.PathStatus.Success then
local nodes = Path:GetWaypoints()
for i, node in pairs(nodes) do
local nodePart = Instance.new("Part")
nodePart.Size = Vector3.one
nodePart.Position = node.Position
nodePart.Anchored = true
nodePart.CanCollide = false
nodePart.Parent = workspace
if node.Action == Enum.PathWaypointAction.Jump then
Humanoid.Jump = true
end
Humanoid:MoveTo(node.Position)
Humanoid.MoveToFinished:Wait()
end
else
print("Path could not be calculated.")
end
local PFS = game:GetService('PathfindingService')
local R6 = game.Workspace.R6
local Humanoid = R6.Humanoid
local EndPoint = game.Workspace.EndPoint
local Path = PFS:CreatePath()
Path:ComputeAsync(R6.HumanoidRootPart.Position, EndPoint.Position)
Humanoid.WalkSpeed = 25
if Path.Status == Enum.PathStatus.Success then
local nodes = Path:GetWaypoints()
for i, v in pairs(nodes) do
local node = Instance.new('Part', workspace)
node.Size = Vector3.new(1,1,1)
node.Material = Enum.Material.Neon
node.Position = v.Position
node.Anchored = true
node.CanCollide = false
if v.Action == Enum.PathWaypointAction.Jump then
Humanoid.Jump = true
end
Humanoid:MoveTo(v.Position)
Humanoid.MoveToFinished:Wait(1)
end
end
Nice, I also recommend you use this snippet of code so the NPC doesn’t lag (if you want players to see the NPC):
game.Players.PlayerAdded:Wait()
for i,v in pairs(script.Parent:GetChildren()) do
if v:IsA("BasePart") then
v:SetNetworkOwner(workspace:WaitForChild(game.Players:GetPlayers()[1].Name))
end
end