Yet again I have a another question with humanoid AI ;/ . Bear with me, Ive cerated this script that will find the closest player to a humanoid. Then the humanoids WalkToPoint position will be set as players position. The outputs reads no errors, its just nothing happens. If you dont get it, please copy the script and place a humanoid in your workspace. Here's the script:
diff = 0
comp = 0
Players = game.Players:GetChildren()
human = workspace.Humanoid
function Var(p1,p2)
diff = (p1.Maginitude - p2.Maginitude).Maginitude
end
for i,v in pairs(Players) do
Var = human.Torso.Position , v.Character.Torso.CFrame.p
if comp==0 or diff<comp then
comp = diff
player = v.Character.Torso.CFrame.p
Repeat()
end
end
function Repeat()
repeat
wait(.2)
human.Humanoid.WalkToPoint = player
until Players==nil
end
THX!!

6 comments
If you cannot find out what is going wrong with a script, use the
print()statement to output variables and track the progress of code. It will help you troubleshoot when no errors are present.Roger that sir.
Have you sorted out things like actually enabling the AI to move?
I've tested if the humanoids walktopoint property has worked before. Like I said, if you don't understand, please test it yourself.
You called Repeat() before the function exists, your function Repeat() must be above line 10, where it is called. After that, comment what is happening. Do not forget, you cannot anchor an AI. You also need all necessary parts.
Id like you to post an answer to my question instead of commenting. I want to make sure I get closure for all of my questions.