This event fires when the
Humanoid finishes walking to a goal declared by the
Humanoid/WalkToPart properties can be set individually, or using the
Humanoid reaches its goal within 8 seconds, this event will return with reached as true. If the goal is not reached within 8 seconds the
Humanoid will stop walking and reached will be false. This timeout can be reset be calling
Humanoid/MoveTo again within the timeout period.
True if the
Humanoid MoveTo Without Time out
This code sample includes a function that avoids the 8 second timeout on
Humanoid/MoveTo by calling
Humanoid/MoveTo again before the timeout elapses. It also includes an optional andThen parameter where developers can pass a function to be called when the humanoid reaches its destination.
local function moveTo(humanoid, targetPoint, andThen) local targetReached = false -- listen for the humanoid reaching its target local connection connection = humanoid.MoveToFinished:Connect(function(reached) targetReached = true connection:Disconnect() connection = nil if andThen then andThen() end end) -- start walking humanoid:MoveTo(targetPoint) -- execute on a new thread so as to not yield function spawn(function() while not targetReached do -- does the humanoid still exist? if not (humanoid and humanoid.Parent) then break end -- has the target changed? if humanoid.WalkToPoint ~= targetPoint then break end -- refresh the timeout humanoid:MoveTo(targetPoint) wait(6) end -- disconnect the connection if it is still connected if connection then connection:Disconnect() connection = nil end end) end