function moveTo(humanoid, targetPoint, targetItem)
   	local targetReached = false
   	local connection
   	connection = humanoid.MoveToFinished:Connect(function(reached)
   		targetReached = true
		connection:Disconnect()
		connection = nil
   	end)

   	humanoid:MoveTo(targetPoint)

   	spawn(function()
		while not targetReached do
			if not (humanoid and humanoid.Parent) then
				break
			end
			if humanoid.WalkToPoint ~= targetPoint then
				break
			end
			humanoid:MoveTo(targetPoint)
			wait(6)
		end
		
		if connection then
			connection:Disconnect()
			connection = nil
		end
	end)
end

I stole most of it from the wiki since I wasn't too good with stuff like this. It works the first time and then when it gets called again it just gives up. It doesn't give any errors, but it acts like its actually walking but it stays in place.

2 comments

0

on line 3 it just says local connection, i think it would error

0

@guywithapoo that bit's fine. it'll default to nil. i think it's something outside the code. i didn't have any issues with running it twice. it's the same code from this page, but he removed the bit about calling a passed in function after the movement is finished. what are your coordinates that you're trying to move to?