Put player in spectator at 10 deaths

So I want a player to get put into spectator mode on 10 deaths. i have made a scoreboard already called Deaths and i have this: execute as s@ run gamemode spectator if score @s Deaths matches 10
in a tick.mcfunction file. i geuss its wrong but what do i put instead to make it work? im in 1.20.1 and new with this stuff.
Continue to help post