Here is the original script regardless - the line as mentioned in the OP being line 61
--!strict
local Service = {
Path = game:GetService("PathfindingService")
}
type Agent = {
Main:BasePart,
Target:BasePart?,
Stats:{
WalkSpeed:number,
RunSpeed:number,
Health:number,
MaxHealth:number,
Frequency:number
},
Path:{
Waypoints:{PathWaypoint?},
Index:number,
Path:Path?
}
}
local Agent:Agent = {
Main = script.Parent,
Target = workspace.Target,
Stats = {
WalkSpeed = 1,
RunSpeed = 2,
Health = 100,
MaxHealth = 100,
Frequency = 1/4
},
Path = {
Waypoints = {},
Index = 0
}
}
function Step()
local currentStep = Agent.Path.Waypoints[Agent.Path.Index]
local nextStep = Agent.Path.Waypoints[Agent.Path.Index+1]
Agent.Path.Index += 1
local pos = nextStep and nextStep.Position or (currentStep and currentStep.Position or Agent.Main.Position)
local dir = (nextStep and nextStep.Position or Agent.Main.CFrame.LookVector * 999) - Agent.Main.Position
Agent.Main.CFrame = CFrame.new(pos,dir) + Vector3.new(0,Agent.Main.Size.Y/2,0)
end
function Path(too:Vector3|nil,from:Vector3|nil)
too = too or (Agent.Target ~= nil and Agent.Target.Position or Agent.Main.Position)
from = from or Agent.Main.Position
if (too-from).Magnitude < 4 then return end
local path = Service.Path:CreatePath({
AgentRadius = 1,
AgentHeight = 1,
AgentCanJump = false,
-- New parameter --
Costs = {
Grass = 10
}
})
path:ComputeAsync(from,too)
Agent.Path.Path = path
end
Path()