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

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
