Why would I use a while true do? the target is not changing at the moment for testing purposes. Using a while true do Is an unnecessary method which would damage performance.
Yeah but the :MoveTo() function is kinda weird. That has also happened to me, then I used while true do and it fixed. I would recommend you to at least try using it.
local Torso = script.Parent:WaitForChild("Torso")
local Velocity = Torso.Velocity
Torso.Changed:Connect(function()
if Velocity.Magnitude < 3 then -- If the entity is not moving
-- Repeat the MoveTo function
end
end
For the purpose of archive, here is the solution I found best and am currently using
function RetargetGroup(Group, Checks)
Group.Arrived = false
for i,v in pairs(Group.Members) do
local Position = GetRandomInPart(Group.CurrentTarget).p
local Check = 0
v.Humanoid:MoveTo(Position)
Func = v.Humanoid.MoveToFinished:Connect(function()
Check = Check + 1
if Check == Checks then
Func:Disconnect()
else
v.Humanoid:MoveTo(Position)
end
end)
end
end
Basically you give an estimate of segments of 8s it will take for the humanoid to reach the target (always over estimate) then when that estimate is reached it cancels the moveto