Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Help with Artificial Intelligence?

Asked by 5 years ago
Edited 5 years ago

I am trying to make an ai follow you, then stop if it gets to close. but for some reason it works when i do mag >= 4 and doesn't work when i do mag <= 4 (which is what i am trying to do)

function killhuman()
    for i,v in pairs(game.Workspace:GetChildren()) do
        if v:FindFirstChild("Humanoid") then
            local mag = (v.Head.Position - script.Parent.Head.Position).magnitude
            local human = script.Parent.Humanoid
            if mag >= 4 then
                print("Too Close")
            end
            if mag <= 10 then
                human:MoveTo(v.Head.Position)
            end
        end
    end
end

while wait() do
    killhuman()
end

1 answer

Log in to vote
-1
Answered by 5 years ago

:MoveTo() is not a method anymore. It is movetopart or movetocframe I believe. I think it even shows you the methods name in the properties of the Humanoid element.

0
According to the wiki, MoveTo isn't deprecated mattscy 3725 — 5y
0
deprecated means that it is gonna get removed. It is removed. ClockWallie 28 — 5y
Ad

Answer this question