Hello,

I want to detect Mobs/Humanoid and then walk auto to it within a distance of XXX … I have searched a lot but cant find the script for it.. I found some similar script but I dont know how to Change it that it go to Mobs/Humanoid. Thanks a lot!

 while wait(1) do
local function GetObject()
        local least = math.huge
        local Object    
        for _,Stuff in pairs (workspace:GetDescendants()) do
            if Stuff:IsA("MeshPart") then
                if Stuff.MeshId == "rbxassetid://2542638609" or Stuff.MeshId == "rbxassetid://2542638609" or Stuff.MeshId == "rbxassetid://2558194071" or Stuff.MeshId == "rbxassetid://2558179804" then
                    local Distance = game.Players.LocalPlayer:DistanceFromCharacter(Stuff.Position)
                    if Distance < least and Distance < 120 then
                        least = Distance
                        Object = Stuff
                    end
                end
            end
        end
        return Object
    end
  
       if GetObject() ~= nil then game.Players.LocalPlayer.Character.Humanoid:MoveTo(GetObject().Position)
    end

2 comments

0

(game.Players.LocalPlayer.Character.HumanoidRootPart.Position - Part.Position).Magnitude < 120

0

Thanks... But how I get it move it? I dont see there code like MoveTo