Here from the video, you can see how the animation is being played. Whenever a player is in the distance of the humanoid, the bot will follow the player, but the animations looks weird. Very Weird.
here is the script.
local char = script.Parent
local humanoid = char:WaitForChild('Humanoid')
local walkAnim = script:WaitForChild('WalkAnim')
local walkAnimTrack = humanoid.Animator:LoadAnimation(walkAnim)
local dist = 100
local function findNearestTorso(pos)
local list = game.Workspace:children()
local torso = nil
local temp = nil
local human = nil
local temp2 = nil
for x = 1, #list do
temp2 = list[x]
if (temp2.className == "Model") and (temp2 ~= script.Parent) then
temp = temp2:findFirstChild("Torso")
human = temp2:findFirstChild("Humanoid")
if (temp ~= nil) and (human ~= nil) and (human.Health > 0) then
if (temp.Position - pos).magnitude < dist then
walkAnimTrack:Play()
torso = temp
dist = (temp.Position - pos).magnitude
elseif (temp.Position - pos).magnitude > dist then
walkAnimTrack:Stop()
end
end
end
end
return torso
end
while true do
wait(0.1)
local target = findNearestTorso(script.Parent:WaitForChild('MiddleTorso').Position)
if target ~= nil then
script.Parent:WaitForChild('Humanoid'):MoveTo(target.Position, target)
end
end
Note: This is a script from tutorial/tooblox. I just looked at the code, understood what was going on and redid some aspects
Any help is appreciated.