Trying to move a model using tweens for each part by moving it by adding the distance from endPart to its vector position.
function followPath(destination, part)
-- Compute the path
local success, errorMessage = pcall(function()
path:ComputeAsync(part.Position, destination)
end)
local tweenPart
if success and path.Status == Enum.PathStatus.Success then
waypoints = path:GetWaypoints()
for i, v in pairs(waypoints) do
local node = Instance.new("Part")
node.Size = Vector3.new(1,1,1)
node.Position = v.Position
node.Anchored = true
node.CanCollide = false
node.Parent = workspace
local dist = v.Position - part.Position
tweenPart = TS:Create(part, TweenInfo.new(dist.Magnitude / 10, Enum.EasingStyle.Linear), {Position = Vector3.new(part.Position.X - dist.X, part.Position.Y - dist.Y, part.Position.Z - dist.Z)})
tweenPart:Play()
task.wait(dist.Magnitude / 10)
print("a")
end
else
warn("Path not computed!", errorMessage)
end
end
function walk(model)
canDoAiThings = false
local area = model.Parent
local aiParts = area.AiParts:GetChildren()
local randomPart = aiParts[math.random(1, #aiParts)]
local dist = (model.PrimaryPart.Position - randomPart.Position)
for i, v in pairs(model:GetDescendants()) do
if v:IsA("Part") or v:IsA("BasePart") or v:IsA("MeshPart") then
followPath(randomPart.Position, v)
end
end
task.wait(dist.Magnitude / 10)
canDoAiThings = true
end
https://gyazo.com/7c7162b5670f142889ed0dd722b266b2
Sometimes the model moves, but like halfway of its first waypoint