Hello, I’m currently working on this SCP Game and I’m trying to make a passive AI currently the script works but I want it to move from Destination1 to Destination2 every 15 seconds. I currently just added a wait statement then copied and paste the code and changed it to Destination 1 but that won’t work because I have a line of code limit.
Code:
local pathfindingService = game:GetService(“PathfindingService”)
local humanoid = script.Parent.Humanoid
local body = script.Parent:FindFirstChild("HumanoidRootPart") or script.Parent:FindFirstChild("Torse")
local Destination1 = game.Workspace.Destination1.Position
local path = pathfindingService:CreatePath()
path:ComputeAsync(body.Position, Destination1)
local waypoint = path:GetWaypoints()
for k, waypoint in pairs(waypoint) do
humanoid:MoveTo(waypoint.Position)
if waypoint.Action == Enum.PathWaypointAction.Jump then
humanoid:changeState(Enum.HumanoidStateType.Jumping)
end
humanoid.MoveToFinished:Wait()
end