#Reset Last Level
setblock -32 55 152 polished_blackstone_button[powered=false,face=floor,facing=west]

#Next Level
execute in overworld run tp @p[x=-32,y=55,z=152,distance=..6] 40.53 148.00 104.48 179.40 7.35
playsound block.note_block.chime master @p[x=40.53,y=148.00,z=104.48,distance=..1] 40.53 148.00 104.48 1 2


#Reset Inventory
clear @p[x=40.53,y=148.00,z=104.48,distance=..1]
scoreboard players reset @s level

#End
title @p[x=40.53,y=148.00,z=104.48,distance=..1] title {"text":"Congratulations!","bold":true,"color":"green"}
title @p[x=40.53,y=148.00,z=104.48,distance=..1] subtitle {"text":"You have completed all the levels.","color":"green"}
tellraw @a ["",{"selector":"@p[x=40.53,y=148.00,z=104.48,distance=..1]","bold":true,"color":"gold"}," has completed all ",{"score":{"name":"levels","objective":"totalLevels"},"color":"gold"}," levels!"]
tellraw @p[x=40.53,y=148.00,z=104.48,distance=..1] "\n"
tellraw @p[x=40.53,y=148.00,z=104.48,distance=..1] ["","Feel free to send feedback to ",{"text":"affe","bold":true,"color":"gold"},{"text":"#","color":"gold"},{"text":"3506 ","bold":true,"color":"gold"},"on discord."]
tellraw @p[x=40.53,y=148.00,z=104.48,distance=..1] "\n"
tellraw @p[x=40.53,y=148.00,z=104.48,distance=..1] ["","Special gratitude to ",{"text":"disruptivebuilds","bold":true,"underlined":true,"color":"light_purple","clickEvent":{"action":"open_url","value":"https://www.instagram.com/disruptive_builds/?hl=en"}}," for allowing major build inspiration for several levels."]