Robot Pathfinding

Screenshot 2021-06-04 at 10.32.15

got rid of the other mesh just to make the process quicker.

show me the output, and the current script

No. Thats not what i meant, i said to use an instance called “Weld” not “WeldConstraint”

This is how you use Weld if you dont know about it Weld | Roblox Creator Documentation

Or use this plugin Weld - Roblox if you dont know how to use it

what’s the difference of using weld and weldconstrait

Ok wait 2 secs (that could be the problem).

Oh im dumb. Sorry its just that im used to Weld more than WeldConstraint

You need a humanoid and the model needs to be rigged to use pathfinding. You need a head part, and a HumanoidRootPart.

Pathfinding isn’t the best way to achieve this, I suggest lerping or tweening it instead.

1 Like

Nope just leaves the other parts, even if welded.

Never tried them. Will they still find the best path to the part?

You have to decide which way it’s going to go, you could have multiple nodes and choose a random start point.

Pathfinding doesn’t do this at all, it just finds the most direct route. You will have to make your robot jump so that it doesn’t get stuck, but for a cleaning robot, I doubt that will look good if it just jumps over walls.

That was another idea. But I want to use it as it directs players to a place with the robot moving and go around any obstacles which would pathfinding would fix. But Lerping and Tweaking I think it just in a straight line and doesn’t change even if there is obstacles in the way.

I used your code and I came up with this:
The green part is the welded part, I made the base part(the grey one) anchored for this
https://i.gyazo.com/45a34b9b7ca2763638a4d1485a90a066.gif
Screenshot 2021-06-04 194949

I weld it using EasyWeld from Moon Animator

wait(5)
local start = script.Parent

local finish = game.Workspace.EndPart

local PathfindingService = game:GetService("PathfindingService")
local path = PathfindingService:CreatePath()
path:ComputeAsync(start.Position, finish.Position)

local waypoints = path:GetWaypoints()

coroutine.wrap(function() -- Debug Remove if you want
	for i, waypoint in pairs(waypoints) do
		local part = Instance.new("Part")
		part.Name = i
		part.Shape = "Ball"
		part.Material = "Neon"
		part.Size = Vector3.new(0.6, 0.6, 0.6)
		part.Position = waypoint.Position
		part.Anchored = true
		part.CanCollide = false
		part.Parent = start
	end
end)()

local oldPos = start.Position
for _, waypoint in pairs(waypoints) do
	repeat
		local newPos = waypoint.Position
		game:GetService("TweenService"):Create(start, TweenInfo.new(0.5), {CFrame = CFrame.new(oldPos, newPos-oldPos)}):Play()
		oldPos = newPos
	
		wait(0.5)
	until (start.Position - waypoint.Position).Magnitude <= 5
end

Yeah I just realised that, pathfinding returns waypoints, so you can just lerp to those points.

Tween service won’t move welded part,Try use a humanoid or body position or Model:MoveTo()

Maybe group all the parts and put the script inside?