I have a network of waypoints and NPCs, the movement between points all work fine. However, I cannot make the NPCs use their walking animation. They currently just stand still while moving. I have the script "Animate"
set up (disabled as a child of main script) yet it still doesn’t work.
local pfs: PathfindingService = game:GetService("PathfindingService")
local ids: {number} = {1220039795, 1732675611, 3323364481, 1466878036}
local waypoints: Folder = workspace.Map.LobbyNPCs.Waypoints
for _, v: number in ids do
local rig = game:GetService("Players"):CreateHumanoidModelFromUserId(v)
rig.Humanoid.DisplayDistanceType = Enum.HumanoidDisplayDistanceType.None
rig.HumanoidRootPart:PivotTo(waypoints:GetChildren()[math.random(#waypoints:GetChildren())]:GetPivot())
rig.Parent = workspace.Map.LobbyNPCs
local clonedAnimateScript = script.Animate:Clone()
clonedAnimateScript.Parent = rig
clonedAnimateScript.Enabled = true
task.spawn(function()
while true do
local waypoint = waypoints:GetChildren()[Random.new():NextInteger(1, #waypoints:GetChildren())]
local path = pfs:CreatePath({
AgentCanJump = false;
Costs = {
LobbyNPCBarrier = math.huge;
}
})
local success = pcall(function()
path:ComputeAsync(rig.HumanoidRootPart.Position, waypoint.Position)
end)
if success and path.Status == Enum.PathStatus.Success then
for _, point in path:GetWaypoints() do
rig.Humanoid:MoveTo(point.Position)
rig.Humanoid.MoveToFinished:Wait()
end
end
task.wait(math.random(2, 5))
end
end)
end