hey, does anyone know how to fix my code? this is a script that makes a character follow the closest player, however it’s quite jittery(?) because it’s running on a while loop
while task.wait() do
for i, character in workspace:GetChildren() do
if not
(character:IsA("Model") and
character:FindFirstChild("Humanoid") and
players:GetPlayerFromCharacter(character)
)
then
continue
end
local char_rootpart = character:WaitForChild("HumanoidRootPart")
if (char_rootpart.Position - abyssal_hrp.Position).Magnitude < max_distance then
abyssal_humanoid:MoveTo(char_rootpart.Position)
target = character.Name
print(target)
end
end
end
if anyone has any alternative or solutions, please help me out! thank you :))