Script not saving. Extra keys not allowed

My cover.toggle is not working so i wanted to use this script I found online.
But I get the error: Message malformed: extra keys not allowed @ data[‘script’]

The script want to use is:

“”""""""

script:
toggle_cover:
sequence:
- service_template: >
{% if is_state(‘cover.gordijn2’, ‘open’) %}
cover.close_cover
{% else %}
cover.open_cover
{% endif %}
entity_id: cover.gordijn2

“”""""""

Where is that example located in your configuration?

If it is in scripts.yaml then it doesn’t need the first line containing script:

If you are creating the script using the Script Editor, then it also doesn’t need the first line containing script: and it may require modifying the second line.

I used this when creating an script. I am new to HA so i would know another way to implement this script.

That didn’t answer my question. I can’t help you until I know where you put all of that YAML code. I suspect you put it into the scripts.yaml file where it’s unnecessary to include what you have on the first line.