Hello, I’m trying to make it so a monster moves towards a player. I have this fully rigged (I think) monster. The monster rig I made myself and I also rigged myself so IDK if I did it wrong or something. I just used motor6ds and welds. Anyways I have a path finding script but it always says
Enum.PathStatus.NoPath
My script is:
local function Attack()
print("attacking")
while target ~= nil do
task.wait()
local path : Path = PFS:CreatePath({
AgentRadius = 3,
AgentHeight = 6,
AgentCanJump = true,
Costs = {
Water = 20
}
})
local success, result = pcall(function()
path:ComputeAsync(monster.HumanoidRootPart.Position, target.Character.HumanoidRootPart.Position)
end)
if success and path.Status == Enum.PathStatus.Success then
for _, waypoint : PathWaypoint in pairs(path:GetWaypoints()) do
hum:MoveTo(waypoint.Position)
hum.MoveToFinished:Wait()
end
else
print(path.Status) -- prints Enum.PathStatus.NoPath 24/7
end
end
end
The entire monsters body is welded to one main body piece. That main body piece is connected to the humanoidrootpart via a motor6d. there is also a weld constraint connecting a part named eyes to the humanoidrootpart.
Thanks it worked. btw how do I make my monster not so trash? it looks really poorly made. (I tried breaking the loop so it wouldnt waste time going to a spot the player wasnt already there.) Here is the code:
local function Attack()
while target ~= nil do
print("attacking")
local path : Path = PFS:CreatePath({
AgentRadius = 3,
AgentHeight = 6,
AgentCanJump = true,
Costs = {
Water = 20
}
})
local success, result = pcall(function()
path:ComputeAsync(monster.HumanoidRootPart.Position, target.Character.HumanoidRootPart.Position)
end)
if success and path.Status == Enum.PathStatus.Success then
for _, waypoint : PathWaypoint in pairs(path:GetWaypoints()) do
hum:MoveTo(waypoint.Position)
hum.MoveToFinished:Wait()
if _ == 5 then
break
end
end
else
print(path.Status)
print(success)
print(result)
end
end
end