I'm building a model from scratch, not really sure how to animate it too well, but I'm really more interested in making an AI for it.
It's supposed to move to a player location, but the model does nothing. Whenever I put just the model (dummy:MoveTo(target.Position)) it moves to above the player since the player is in the player position and it can't be there. Is this because I don't have any animations on my model? If I were to add an animation would it walk there instead of teleporting above the player/at player position?
function findPlayer(dummyPosition)
local dist = 1000
local torso = nil
local tempDist = dist
local minDist = dist
for i, player in pairs(game.Players:GetPlayers()) do
if (player ~= nil) then
local tempTorso = player.Character:findFirstChild("HumanoidRootPart")
tempDist = ((tempTorso.Position - dummyPosition).magnitude)
if ((tempDist)< dist)then
if (tempDist < minDist) then
torso = tempTorso
minDist = tempDist
end
end
end
end
return torso
end
while true do
wait(1)
local target = findPlayer(script.Parent.HumanoidRootPart.Position)
if target ~= nil then
print(target.Position)
dummy.Humanoid:MoveTo(target.Position)
end
end

1 comment
Why exactly is the MoveTo() not working? Is it because of the model having no animation? I haven't even played Roblox. I've spent two days in the Roblox Studio. If I set a primary part with CFrames, would that allow my MoveTo() function to work? Or would I have to manually get it to glide to it's desired location?