MoveTo() delaying when the enemy spawn

My MoveTo() is having delay, after the enemy complete the spawn animation, he delays for 1 second and follow the nearest player.

The script:

while wait(0.1) do
		if not enemy:FindFirstChild('Humanoid') then
			break
		end
		if enemy.PrimaryPart:FindFirstChild('Zone') then
			for _, s in pairs(workspace:GetPartsInPart(enemy.PrimaryPart:WaitForChild('Zone'), OP)) do
				if s.Parent:FindFirstChild("Humanoid") then
					if game.Players:GetPlayerFromCharacter(s.Parent) then
						if game.Players:GetPlayerFromCharacter(s.Parent).Safe.Value == false and s.Parent.Humanoid.Health > 0 then
							detect(s.Parent)
						end
					end
				end
			end
			if state == false then
				QuickDistance = math.huge
				target = nil
			end
			state = false
			if enemy:FindFirstChild('Moving') then
				if target ~= nil and enemy.PrimaryPart:FindFirstChild('Hitbox') then
					enemy.Humanoid:MoveTo(target.PrimaryPart.Position)
					enemy.Moving.Value = true
					enemy.Humanoid.MoveToFinished:Connect(function()
						enemy.Moving.Value = false
					end)
				elseif (enemy.PrimaryPart.Position - pos).Magnitude > 0.05 then
					enemy.Humanoid:MoveTo(pos)
					enemy.Moving.Value = true
					enemy.Humanoid.MoveToFinished:Connect(function()
						enemy.Moving.Value = false
					end)
				end
			end
			target = nil
			QuickDistance = math.huge
		end
	end
local function detect(char)
		local calc = (enemy.PrimaryPart.Position - char.PrimaryPart.Position).Magnitude
		state = true
		if calc < QuickDistance then
			QuickDistance = calc
			target = char
		end
	end

I’m having this problem for 12 days, no one have this problem too?