function onBegin()
	playSound("event:/CrossoverCollab/Xelk1/SFX/LevelComplete")
	setFlag("endCirclePre",true)
	wait(0.125)
	setFlag("endFadingBeams",true)
	wait(0.25)
	setFlag("endCircleA",true)
	wait(0.1)
	setFlag("endCirclePre",false)
	setFlag("endCircleB",true)
	wait(0.1)
	setFlag("endCircleC",true)
	wait(0.1)
	setFlag("endCircleParticlesA",true)
	setFlag("endFadingBeams",false)
	wait(0.1)
	setFlag("endCircleParticlesB",true)
	wait(0.1)
	setFlag("endCircleParticlesC",true)
	wait(0.05)
	setFlag("endCircleA",false)
	wait(0.1)
	setFlag("endCircleB",false)
	wait(0.1)
	setFlag("endCircleC",false)
	wait(0.25)
	setFlag("endCircleParticlesA",false)
	wait(0.1)
	setFlag("endCircleParticlesB",false)
	wait(0.1)
	setFlag("endCircleParticlesC",false)
	wait(0.65)
	setFlag("endSongCoinOutline",true)
	for i=1,3,1 do
		if getFlag("song5coin"..tostring(i)) then
			setFlag("song5coin"..tostring(i).."Display",true)
		end
	end
	wait(0.5)
	
	while true do
		if (celeste.Input.Jump.Pressed or celeste.Input.DashPressed or celeste.Input.CrouchDashPressed or celeste.Input.MenuConfirm.Pressed) then
			onEnd()
			teleportTo(164,-16,"menu5","Transition")
				player.Facing = getEnum("Celeste.Facings", "Right")
		end
		wait()
	end
end

function onEnd()
	setFlag("endFadingBeams",false)
	setFlag("endCirclePre",false)
	setFlag("endCircleA",false)
	setFlag("endCircleB",false)
	setFlag("endCircleC",false)
	setFlag("endCircleParticlesA",false)
	setFlag("endCircleParticlesB",false)
	setFlag("endCircleParticlesC",false)
	setFlag("endSongCoinOutline",false)
	for i=1,6,1 do
		for j=1,3,1 do
			setFlag("song"..tostring(i).."coin"..tostring(j).."Display",false)
		end
	end
end