I tried implementing this on a default dummy, and it seems to work, until I tried it on a deer model. It prints out “Failed to create path to Plectocron!” from my server script. Here’s the server script:
local RunService = game:GetService(“RunService”)
– Require the Pathfinding module
local PathfindingService = game:GetService(“PathfindingService”)
local Path = require(game.Workspace.SimplePath) – Assuming your pathfinding script is named “Pathfinding”
– Get references to Dummy and Plectocron
local dummy = script.Parent
local plectocron = workspace:WaitForChild(“Plectocron”) – Replace with actual path to Plectocron
local agent = {
AgentRadius = 5, – Set the agent radius
AgentHeight = 5, – Set the agent height
AgentCanJump = true, – Set whether the agent can jump
– Add any other relevant parameters here
}
– Function to update the target and start chasing
local function chasePlectocron()
local targetPosition = plectocron.PrimaryPart.Position
local path = Path.new(dummy, agent)
local success = path:Run(targetPosition)
if not success then
print(“Failed to create path to Plectocron!”)
end
end
– Call chasePlectocron initially and repeatedly
chasePlectocron()
RunService.Heartbeat:Connect(function()
chasePlectocron()
end)