How can I return only 1 random block in a Matrix in Craft using Twig? I have a matrix with a couple of text fields for a caption, location and URL and an image

Every time this page loads I want a random slide to show - so the background image is random, as well as the relevant text fields.

I've tried several variations of the below but keep getting a template error of "Array to string conversion"

Why is this happening? How can I achieve the desired result?

{% if entry.carouselMatrix is not empty %}
    {% set currentSlide = shuffle(entry.carouselMatrix.slides).first() %}
    &lt;div class="hero__wrapper"&gt;
        {% for slide in currentSlide.first() %}
            {% set image = slide.image.first() %}
            &lt;div class="hero__image" style="background-image: url('{{ image.getUrl('heroHome') }}');"&gt;&lt;/div&gt;
            &lt;div class="hero__wrapper--inner grid"&gt;
                &lt;h1 class="hero__text grid__item desk-two-thirds"&gt;
                    {{ entry.heroText }}
                &lt;/h1&gt;
            &lt;/div&gt;
            &lt;div class="hero__image--caption"&gt;
                &lt;a href="{{ slide.linkUrl }}"&gt;
                    &lt;span&gt;{{ slide.caption }}&lt;/span&gt;
                &lt;/a&gt;
            &lt;/div&gt;
        {% endfor %}
    &lt;/div&gt;
{% endif %}
You can create a random order by including rand() in your OrderBy function.

{% set randomBlock = entry.carouselMatrix.orderBy('rand()').one() %}
{% if randomBlock is not null %}
    {% set randomSlide = randomBlock.slides.orderBy('rand()').one() %}
    {% if randomSlide is not null %}
        {{ randomSlide .caption }}
        {% set image = randomSlide.image.one() %}
        {{ image is not null? image.getUrl() : '' }}
    {% endif %}
{% endif %}