Hi I wanna create a datapack for my Server.

Basically if a player dies they should get banned for 24 hours. And a function that checks users gamemode and if its not survival it changes it to survial. I tried following some tutorials but it didnt work.

as an example death.mcfunction

scoreboard objectives add deaths deathCount
scoreboard objectives add ban dummy
scoreboard players set @a ban 0

execute as @a[scores={deaths=1..}] run scoreboard players set @s ban 1
execute as @a[scores={deaths=1..},scores={ban=1..}] run ban @s 24h
execute as @a[scores={ban=1..}] run tellraw @s ["",{"text":"Du bist gebannt für noch ","color":"red"},{"score":{"name":"@s","objective":"ban"},"color":"red"},{"text":" Stunden.","color":"red"}]
Continue to help post