I need help, im making an ai that i want to be able to face a certain direction after its done its path. Im using the basic roblox tutorial ai.
this is whats currently hapenning. I want it so that when its done moving it faces towards the shelves. Like this
Is there any way i can do that?
forgot to add the script:
-- Variables --
local PathFolder = workspace.PathLocations
local Pathfinding = game:GetService("PathfindingService")
local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
local path = Pathfinding:CreatePath({
AgentHeight = 6;
AgentRadius = 3;
AgentCanJump = false;
Cost = {
Water = 100;
DangerZone = math.huge
}
})
local Character = script.Parent
local humanoid = Character:WaitForChild("Humanoid")
local waypoints
local nextWaypointIndex
local reachedConnection
local blockedConnection
local random = math.random(1,35)
local route = "p"..random
local locationRoute = PathFolder:WaitForChild(route)
local Location = locationRoute.Position
local function followPath(destination)
local success, errormessage = pcall(function()
path:ComputeAsync(Character.PrimaryPart.Position, destination)
end)
if success and path.Status == Enum.PathStatus.Success then
waypoints = path:GetWaypoints()
blockedConnection = path.Blocked:Connect(function(blockedWaypointIndex)
if blockedWaypointIndex >= nextWaypointIndex then
blockedConnection:Disconnect()
followPath(destination)
end
end)
if not reachedConnection then
reachedConnection = humanoid.MoveToFinished:Connect(function(reached)
if reached and nextWaypointIndex < #waypoints then
nextWaypointIndex += 1
humanoid:MoveTo(waypoints[nextWaypointIndex].Position)
else
reachedConnection:Disconnect()
blockedConnection:Disconnect()
end
end)
end
nextWaypointIndex = 2
humanoid:MoveTo(waypoints[nextWaypointIndex].Position)
end
end
while task.wait() do
followPath(Location)
end
its just the roblox tutorial ai i modified slightly