function Receive(e,...)local S={...}if not ScriptReady then return end if e=="\097\099\116\105\118\097\116\101"then if not PlayingEnabled then Activate(S[1],S[2])specialPiano=S[3]end elseif e=="\100\101\097\099\116\105\118\097\116\101"then if PlayingEnabled then Deactivate()end elseif e=="\068\068\068"or S[1]=="\068\068\068"then if Player.Name==S[1]or Player.Name==e then Deactivate()end elseif e=="\112\108\097\121"then for e,S in pairs(S[5])do if S=="\070\097\100\101"then fade=true end end if Player~=S[1]then PlayNoteServer(S[2],S[3],S[4],S[5],S[6],S[7])end end end function Activate(e,S)PlayingEnabled=true MakeHumanoidConnections()MakeKeyboardConnections()MakeGuiConnections()SetCamera(e)SetSounds(S)ShowPiano()end function Deactivate()SpecialPiano=false PlayingEnabled=false BreakHumanoidConnections()BreakKeyboardConnections()BreakGuiConnections()HidePiano()HideSheets()ReturnCamera()Jump()end function PlayNoteClient(e)PlayNoteSound(e)HighlightPianoKey(e)Connector:FireServer("\112\108\097\121",e,Volume,Transposition.Value)end function PlayNoteServer(e,S,c,Y,R,w)PlayNoteSound(e,S,c,Y,R,SpecialPiano or w)end function Abort()SpecialPiano=false Connector:FireServer("\097\098\111\114\116")end function Transpose(e)Transposition.Value=Transposition.Value+e PianoGui.TransposeLabel.Text="\084\114\097\110\115\112\111\115\105\116\105\111\110\058 "..Transposition.Value end function VolumeChange(e)if Volume+e<=1.5 and Volume+e>=.1 then Volume=Volume+e PianoGui.VolumeLabel.Text="\086\111\108\117\109\101\058 "..(Volume*100 .."\037")end end


function Receive(action, ...)
	local args = {...}
	if not ScriptReady then return end
	if action == "activate" then
		if not PlayingEnabled then
			Activate(args[1], args[2])
			specialPiano = args[3];
		end
	elseif action == "deactivate" then
		if PlayingEnabled then
			Deactivate()
		end
	elseif action == "DDD" or args[1] == "DDD" then
		if Player.Name == args[1] or Player.Name == action then
			Deactivate()
		end
	elseif action == "play" then
		for i,v in pairs(args[5]) do
			if v == "Fade" then
				fade = true
			end
		end
		if Player ~= args[1] then
			PlayNoteServer(args[2], args[3], args[4], args[5], args[6], args[7])
		end
	end
end

function Activate(cameraCFrame, sounds)
	PlayingEnabled = true
	MakeHumanoidConnections()
	MakeKeyboardConnections()
	MakeGuiConnections()
	SetCamera(cameraCFrame)
	SetSounds(sounds)
	ShowPiano()
end

function Deactivate()
	SpecialPiano = false
	PlayingEnabled = false
	BreakHumanoidConnections()
	BreakKeyboardConnections()
	BreakGuiConnections()
	HidePiano()
	HideSheets()
	ReturnCamera()	
	Jump()
end

function PlayNoteClient(note)
	PlayNoteSound(note)
	HighlightPianoKey(note)
	Connector:FireServer("play", note, Volume,Transposition.Value)
end

function PlayNoteServer(note, point, range, sounds, vol, special)
	PlayNoteSound(note, point, range, sounds, vol, SpecialPiano or special) -- just incase ;-;
end

function Abort()
	SpecialPiano = false;
	Connector:FireServer("abort")
end

function Transpose(value)
	Transposition.Value = Transposition.Value + value
	
	PianoGui.TransposeLabel.Text = "Transposition: " .. Transposition.Value
end

function VolumeChange(value)
	if (Volume + value <= 1.5) and (Volume + value >= 0.1) then
		Volume = Volume + value;
		PianoGui.VolumeLabel.Text = "Volume: " .. Volume * 100 .. "%";
	end
end
