local M=game:GetService("\084\119\101\101\110\083\101\114\118\105\099\101")function Tween(N,Z,L,...)local m=TweenInfo.new(L,...)local E=M:Create(N,m,Z)E:Play()E.Completed:wait()end function UnDigify(M)if M<1 or M>61 then return""elseif M==1 then return"\049"elseif M==2 then return"\033"elseif M==3 then return"\050"elseif M==4 then return"\064"elseif M==5 then return"\051"elseif M==6 then return"\052"elseif M==7 then return"\036"elseif M==8 then return"\053"elseif M==9 then return"\037"elseif M==10 then return"\054"elseif M==11 then return"\094"elseif M==12 then return"\055"elseif M==13 then return"\056"elseif M==14 then return"\042"elseif M==15 then return"\057"elseif M==16 then return"\040"elseif M==17 then return"\048"elseif M==18 then return"\113"elseif M==19 then return"\081"elseif M==20 then return"\119"elseif M==21 then return"\087"elseif M==22 then return"\101"elseif M==23 then return"\069"elseif M==24 then return"\114"elseif M==25 then return"\116"elseif M==26 then return"\084"elseif M==27 then return"\121"elseif M==28 then return"\089"elseif M==29 then return"\117"elseif M==30 then return"\105"elseif M==31 then return"\073"elseif M==32 then return"\111"elseif M==33 then return"\079"elseif M==34 then return"\112"elseif M==35 then return"\080"elseif M==36 then return"\097"elseif M==37 then return"\115"elseif M==38 then return"\083"elseif M==39 then return"\100"elseif M==40 then return"\068"elseif M==41 then return"\102"elseif M==42 then return"\103"elseif M==43 then return"\071"elseif M==44 then return"\104"elseif M==45 then return"\072"elseif M==46 then return"\106"elseif M==47 then return"\074"elseif M==48 then return"\107"elseif M==49 then return"\108"elseif M==50 then return"\076"elseif M==51 then return"\122"elseif M==52 then return"\090"elseif M==53 then return"\120"elseif M==54 then return"\099"elseif M==55 then return"\067"elseif M==56 then return"\118"elseif M==57 then return"\086"elseif M==58 then return"\098"elseif M==59 then return"\066"elseif M==60 then return"\110"elseif M==61 then return"\109"else return"\063"end end function IsBlack(M)if M%12==2 or M%12==4 or M%12==7 or M%12==9 or M%12==11 then return true end end function Startup()blocker.Transparency=.9 blocker.CanCollide=true local M=Important.Display local N={}N.Color=Color3.fromRGB(230,230,230)Tween(M,N,1,Enum.EasingStyle.Linear,Enum.EasingDirection.Out,0,false)N={}N.Color=Color3.fromRGB(103,130,147)Tween(M,N,.5,Enum.EasingStyle.Linear,Enum.EasingDirection.Out,0,false)N={}N.Transparency=0 for M,Z in pairs(SynthesiaKeys)do coroutine.resume(coroutine.create(Tween),Z,N,.5,Enum.EasingStyle.Linear,Enum.EasingDirection.Out,0,false)end N={}return end function Shutdown()blocker.Transparency=1 blocker.CanCollide=false local M=Important.Display local N={}N.Transparency=1 for M,Z in pairs(SynthesiaKeys)do coroutine.resume(coroutine.create(Tween),Z,N,.4,Enum.EasingStyle.Linear,Enum.EasingDirection.Out,0,false)end N={}N.Color=Color3.fromRGB(88,88,88)Tween(M,N,.4,Enum.EasingStyle.Linear,Enum.EasingDirection.Out,0,false)N={}return end function SynthesiaSend(M)local N={}local Z local L if IsBlack(M)then Z=Piano.Case.BlackModel:Clone()else Z=Piano.Case.WhiteModel:Clone()end Z.Transparency=0 L=Piano.Keys.Keys:FindFirstChild(M)Z.Position=L.Position Z.Orientation=L.Orientation Z.Parent=Piano.Keys N.Position=Z.Position+Vector3.new(0,4.9,0)Tween(Z,N,.7,Enum.EasingStyle.Linear,Enum.EasingDirection.Out,0,false)N={}Z:Destroy()return end function HighlightPianoKey(M,N)if not Settings.KeyAesthetics then return end local Z=math.ceil(M/12)local L=(M-1)%12+1 local m=Important.KeyboardKeys coroutine.resume(coroutine.create(SynthesiaSend),M)local E=UnDigify(M)if not string.match(E,"\037\097")and not string.match(E,"\037\100")then if E=="\033"then E="\049"elseif E=="\064"then E="\050"elseif E=="\036"then E="\052"elseif E=="\037"then E="\053"elseif E=="\094"then E="\054"elseif E=="\042"then E="\056"elseif E=="\040"then E="\057"end elseif string.match(E,"\037\097")then E=string.upper(E)end if m:FindFirstChild(E)then E=m:FindFirstChild(E)local N={}if IsBlack(M)then N.Color=Color3.fromRGB(170,243,136)Tween(E,N,.15,Enum.EasingStyle.Linear,Enum.EasingDirection.Out,0,false)N={}else N.Color=Color3.fromRGB(131,238,243)Tween(E,N,.15,Enum.EasingStyle.Linear,Enum.EasingDirection.Out,0,false)N={}end N.Color=Color3.fromRGB(237,234,234)Tween(E,N,.15,Enum.EasingStyle.Linear,Enum.EasingDirection.Out,0,false)N={}end return end


local TweenService = game:GetService("TweenService")
function Tween(obj,Goal,Time,...)
    local TwInfo = TweenInfo.new(Time,...)
    local twn = TweenService:Create(obj, TwInfo, Goal)
    twn:Play()
    twn.Completed:wait()
end



function UnDigify(digit)
	if digit < 1 or digit > 61 then
		return ""
	elseif digit == 1 then
		return "1"
	elseif digit == 2 then
		return "!"
	elseif digit == 3 then
		return "2"
	elseif digit == 4 then
		return "@"
	elseif digit == 5 then
		return "3"
	elseif digit == 6 then
		return "4"
	elseif digit == 7 then
		return "$"
	elseif digit == 8 then
		return "5"
	elseif digit == 9 then
		return "%"
	elseif digit == 10 then
		return "6"
	elseif digit == 11 then
		return "^"
	elseif digit == 12 then
		return "7"
	elseif digit == 13 then
		return "8"
	elseif digit == 14 then
		return "*"
	elseif digit == 15 then
		return "9"
	elseif digit == 16 then
		return "("
	elseif digit == 17 then
		return "0"
	elseif digit == 18 then
		return "q"
	elseif digit == 19 then
		return "Q"
	elseif digit == 20 then
		return "w"
	elseif digit == 21 then
		return "W"
	elseif digit == 22 then
		return "e"
	elseif digit == 23 then
		return "E"
	elseif digit == 24 then
		return "r"
	elseif digit == 25 then
		return "t"
	elseif digit == 26 then
		return "T"
	elseif digit == 27 then
		return "y"
	elseif digit == 28 then
		return "Y"
	elseif digit == 29 then
		return "u"
	elseif digit == 30 then
		return "i"
	elseif digit == 31 then
		return "I"
	elseif digit == 32 then
		return "o"
	elseif digit == 33 then
		return "O"
	elseif digit == 34 then
		return "p"
	elseif digit == 35 then
		return "P"
	elseif digit == 36 then
		return "a"
	elseif digit == 37 then
		return "s"
	elseif digit == 38 then
		return "S"
	elseif digit == 39 then
		return "d"
	elseif digit == 40 then
		return "D"
	elseif digit == 41 then
		return "f"
	elseif digit == 42 then
		return "g"
	elseif digit == 43 then
		return "G"
	elseif digit == 44 then
		return "h"
	elseif digit == 45 then
		return "H"
	elseif digit == 46 then
		return "j"
	elseif digit == 47 then
		return "J"
	elseif digit == 48 then
		return "k"
	elseif digit == 49 then
		return "l"
	elseif digit == 50 then
		return "L"
	elseif digit == 51 then
		return "z"
	elseif digit == 52 then
		return "Z"
	elseif digit == 53 then
		return "x"
	elseif digit == 54 then
		return "c"
	elseif digit == 55 then
		return "C"
	elseif digit == 56 then
		return "v"
	elseif digit == 57 then
		return "V"
	elseif digit == 58 then
		return "b"
	elseif digit == 59 then
		return "B"
	elseif digit == 60 then
		return "n"
	elseif digit == 61 then
		return "m"
  	else
    	return "?"
	end
end
function IsBlack(note)
	if note%12 == 2 or note%12 == 4 or note%12 == 7 or note%12 == 9 or note%12 == 11 then
		return true
	end
end

function Startup()
	blocker.Transparency = .9
	blocker.CanCollide = true
	local Display = Important.Display
	local Properties = {}
	Properties.Color = Color3.fromRGB(230, 230, 230)
	Tween(Display,Properties,1,Enum.EasingStyle.Linear,Enum.EasingDirection.Out,0,false)
	Properties = {}
	Properties.Color = Color3.fromRGB(103, 130, 147)
	Tween(Display,Properties,.5,Enum.EasingStyle.Linear,Enum.EasingDirection.Out,0,false)
	Properties = {}
	Properties.Transparency = 0
	for i,v in pairs(SynthesiaKeys) do
		coroutine.resume(coroutine.create(Tween),v,Properties,.5,Enum.EasingStyle.Linear,Enum.EasingDirection.Out,0,false)
	end
	Properties = {}
	return
end

function Shutdown()
	blocker.Transparency = 1
	blocker.CanCollide = false
	local Display = Important.Display
	local Properties = {}
	Properties.Transparency = 1
	for i,v in pairs(SynthesiaKeys) do
		coroutine.resume(coroutine.create(Tween),v,Properties,.4,Enum.EasingStyle.Linear,Enum.EasingDirection.Out,0,false)
	end
	Properties = {}
	Properties.Color = Color3.fromRGB(88, 88, 88)
	Tween(Display,Properties,.4,Enum.EasingStyle.Linear,Enum.EasingDirection.Out,0,false)
	Properties = {}
	return
end


function SynthesiaSend(note1)
	local Properties = {}
	local Sending
	local Key
	if IsBlack(note1) then
		Sending = Piano.Case.BlackModel:Clone()
	else
		Sending = Piano.Case.WhiteModel:Clone()
	end
	Sending.Transparency = 0
	Key = Piano.Keys.Keys:FindFirstChild(note1)
	Sending.Position = Key.Position
	Sending.Orientation = Key.Orientation
	Sending.Parent = Piano.Keys
	Properties.Position = Sending.Position + Vector3.new(0,4.9,0)
	Tween(Sending,Properties,.7,Enum.EasingStyle.Linear,Enum.EasingDirection.Out,0,false)
	Properties = {}
	Sending:Destroy()
	return
end


function HighlightPianoKey(note1,transpose)
	if not Settings.KeyAesthetics then return end
	local octave = math.ceil(note1/12)
	local note2 = (note1 - 1)%12 + 1
	local KeyboardKeys = Important.KeyboardKeys
	
	coroutine.resume(coroutine.create(SynthesiaSend),note1)
	
	local key = UnDigify(note1)
	if not string.match(key,"%a") and not string.match(key,"%d") then
		if key == "!" then
			key = "1"
		elseif key == "@" then
			key = "2"
		elseif key == "$" then
			key = "4"
		elseif key == "%" then
			key = "5"
		elseif key == "^" then
			key = "6"
		elseif key == "*" then
			key = "8"
		elseif key == "(" then
			key = "9"
		end
	elseif string.match(key,"%a") then
		key = string.upper(key)
	end
	if KeyboardKeys:FindFirstChild(key) then
		key = KeyboardKeys:FindFirstChild(key)
		local Properties = {}
		if IsBlack(note1) then
			Properties.Color = Color3.fromRGB(170, 243, 136)
			Tween(key,Properties,.15,Enum.EasingStyle.Linear,Enum.EasingDirection.Out,0,false)
			Properties = {}
		else
			Properties.Color = Color3.fromRGB(131, 238, 243)
			Tween(key,Properties,.15,Enum.EasingStyle.Linear,Enum.EasingDirection.Out,0,false)
			Properties = {}
			
		end
		Properties.Color = Color3.fromRGB(237, 234, 234) --goes back to white
		Tween(key,Properties,.15,Enum.EasingStyle.Linear,Enum.EasingDirection.Out,0,false)
		Properties = {}
	end
	return
end
