----------------------------------
------------FUNCTIONS-------------
----------------------------------


function ShowPiano()
	PianoGui:TweenPosition(
		UDim2.new(0.5, -355, 1, -230),
		Enum.EasingDirection.Out,
		Enum.EasingStyle.Sine,
		.5,
		true
	)
end
function HidePiano()
	PianoGui:TweenPosition(
		UDim2.new(0.5, -380, 1, 0),
		Enum.EasingDirection.Out,
		Enum.EasingStyle.Sine,
		.5,
		true
	)
end
function ShowSheets()
	SheetsGui:TweenPosition(
		UDim2.new(0.5, -200, 1, -520),
		Enum.EasingDirection.Out,
		Enum.EasingStyle.Sine,
		.5,
		true
	)
end
function HideSheets()
	SheetsGui:TweenPosition(
		UDim2.new(0.5, -200, 1, 0),
		Enum.EasingDirection.Out,
		Enum.EasingStyle.Sine,
		.5,
		true
	)
end

function ToggleSheets()
	SheetsVisible = not SheetsVisible
	if SheetsVisible then
		ShowSheets()
	else
		HideSheets()
	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 HighlightPianoKey(note)
	if note < 62 and note > 0 then
		local keyGui = PianoGui.Keys[note]
		if IsBlack(note) then
			keyGui.BackgroundColor3 = Color3.new(50/255, 50/255, 50/255)
		else
			keyGui.BackgroundColor3 = Color3.new(200/255, 200/255, 200/255)
		end
		delay(.5, function() RestorePianoKey(note) end)
	else
		delay(.5, function() RestorePianoKey(note) end)
	end
end
function RestorePianoKey(note)
	if note < 62 and note > 0 then
		local keyGui = PianoGui.Keys[note]
		if IsBlack(note) then
			keyGui.BackgroundColor3 = Color3.new(0, 0, 0)
		else
			keyGui.BackgroundColor3 = Color3.new(1, 1, 1)
		end
	end
end

function PianoKeyPressed(Object, note)
		local type = Object.UserInputType.Name
		if type == "MouseButton1" or type == "Touch" then
			PlayNoteClient(note)
		end
end

function ExitButtonPressed(Object)
	local type = Object.UserInputType.Name
	if type == "MouseButton1" or type == "Touch" then
		Deactivate()
	end
end

function SheetsButtonPressed(Object)
	local type = Object.UserInputType.Name
	if type == "MouseButton1" or type == "Touch" then
		ToggleSheets()
	end
end

function ToggleCaps()
	ShiftLock = not ShiftLock
	if ShiftLock then
		PianoGui.CapsButton.BackgroundColor3 = Color3.new(1, 170/255, 0)
		PianoGui.CapsButton.BorderColor3 = Color3.new(154/255, 103/255, 0)
		PianoGui.CapsButton.TextColor3 = Color3.new(1, 1, 1)
	else
		PianoGui.CapsButton.BackgroundColor3 = Color3.new(140/255, 140/255, 140/255)
		PianoGui.CapsButton.BorderColor3 = Color3.new(68/255, 68/255, 68/255)
		PianoGui.CapsButton.TextColor3 = Color3.new(180/255, 180/255, 180/255)
	end
end

function CapsButtonPressed(Object)
	local type = Object.UserInputType.Name
	if type == "MouseButton1" or type == "Touch" then
		ToggleCaps()
	end
end
