Search code examples
luaroblox

Humanoid:MoveTo() doesn't work | Roblox LUA


So i'm trying to make a little bot that moves to a point in the map Here is my code :

local character = script.Parent
local humanoid = character.Humanoid
local testpoint = character.Parent.Points["End Part 2"].Position

humanoid:MoveTo(testpoint)
humanoid.MoveToFinished:Connect(function()
    print("Reached Dest")
end)

when i launch the game, the dummy model doesn't move at all (even if WalkToPoint have been correctly set) and then after a few seconds the message Reached Dest prints in the console but the humanoid hasn't move. I have no idea why this happend, could you please help me. Thank you so much.


Solution

  • I have seen problems before with trying to store an instances attribute in a variables. You should try:

    local character = script.Parent
    local humanoid = character.Humanoid
    local testpoint = character.Parent.Points["End Part 2"]
    
    humanoid:MoveTo(testpoint.Position)
    humanoid.MoveToFinished:Connect(function()
        print("Reached Dest")
    end)
    

    Also please make sure you are getting the previous variables correctly like character and humanoid