I have a problem with my script that has :Moveto() because i wanted to try something new. I have a charcater1 and character2, I want the character 1 to move to a humanoid (or character2), it does work however, after i move the charcater2 from its spot, character 1 still doesn’t follow but rather goes to the old position of character 2. This is my script
local torsoop = script.Parent.Torso
local hum = script.Parent.Humanoid
local function findtarget()
local distance = 10
local target = nil
for i, v in pairs(game.Workspace:GetChildren()) do
print(v)
local human = v:FindFirstChild("Humanoid")
local tors = v:FindFirstChild("Torso")
if human and tors and v ~= script.Parent then
if (torsoop.Position - tors.Position).magnitude > distance then
distance = (torsoop.Position - tors.Position).magnitude
print(distance)
target = tors
end
end
end
return target
end
while wait(1) do
local torso = findtarget()
if torso then
hum:MoveTo(torso.Position)
end
end