So I was just trying to code a doors-like entity but the pathfinding is being extremely buggy.
The issue as you can see in the video is that it keeps going back and forth against a part. I’ve tried everything, I tried adding a pathfinding modifier to the part, I tried making a part enveloping the part and added a pathfinding modifier to that, but nothing works. Keep in mind that all the parts here are anchored and collision off.
Here is a chunk of my code that handles the pathfinding, although I cannot send the entire code due to it being incredibly long
function move(entity, target)
local PathfindingService = game:GetService("PathfindingService")
local Humanoid = entity.Humanoid
local path = PathfindingService:CreatePath()
path:ComputeAsync(entity.PrimaryPart.Position, target.Position)
local waypoints = path:GetWaypoints()
print(path.Status)
for i, waypoint in ipairs(waypoints) do
local node = game.ServerStorage.NODE:Clone()
node.Parent = game.Workspace
node.Position = waypoint.Position
node.Touched:Connect(function()
node:Destroy()
end)
end
for i, waypoint in ipairs(waypoints) do
TweenModelToCFrame(entity, TweenInfo.new(.1), CFrame.new(waypoint.Position))
wait(0.01)
end
if game.Workspace.CurrentRooms:FindFirstChild(tostring(tonumber(target.Parent.Parent.Name) + 1)) then
return game.Workspace.CurrentRooms:FindFirstChild(tostring(tonumber(target.Parent.Parent.Name) + 1))
else
entity:Destroy()
game.ServerScriptService.HellFireReset:Fire()
end
end
game:GetService("RunService").Heartbeat:Connect(function()
if not moving then
moving = true
local roomslist = game.Workspace.CurrentRooms:GetChildren()
local nexttarget = move(entity, nexttarget.PlaceHolder.Entrance)
task.wait()
moving = false
end
end)
Any help would be appreciated!