Does any one know what the problem is with this script?
local part = script.Parent
local pathFinder = game:GetService("PathfindingService")
local path = pathFinder:CreatePath()
while true do
path:ComputeAsync(part.Position, workspace.EndingForPart.Position)
for i, wayPoint in pairs(path:GetWaypoints()) do
part.Humanoid:MoveTo(wayPoint.Position)
if wayPoint.Action == Enum.PathWaypointAction.Jump then
part.Humanoid:ChangeState(Enum.HumanoidStateType.Jumping)
end
part.Humanoid.MoveToFinished:wait()
end
end
parts don’t have humanoids, so using part.Humanoid:MoveTo() doesn’t do anything and causes it to break. @pumpkyrofl is saying to use bodymovers to move the part, or use tweenservice to CFrame the part manually as parts do not have MoveTo() and can’t move by themselves.
Based on the provided script, it appears to be a pathfinding script that continuously computes a path for a humanoid to move towards a specific endpoint. However, there are a few potential issues with the script:
The script is in an infinite loop with no way to exit. This may cause performance issues and can potentially crash the game.
The path is being computed every iteration of the loop, which can also cause performance issues.
There is no check to see if the pathfinding actually found a valid path. If a path cannot be found, the script will still continue to execute.
Here are some potential solutions to these issues:
Add a condition to break out of the loop, such as a boolean value that can be set to false when the script needs to stop.
Compute the path only when necessary, such as when the endpoint has moved or the humanoid has moved a certain distance from the previous endpoint.
Check the result of the pathfinding computation to see if a valid path was found, and handle the case where no path was found accordingly.
Overall, without more context on what the script is supposed to do and what the desired behavior is, it is difficult to provide a more specific solution.