Just like bonsai said ,
you could make an button over you rectangel , set its alpha to 0 so you cant see it ,
and just handle it like a normal button.
button = guiCreateButton(x,y,w,h, "button", false)
guiSetAlpha(button, 0)
dxDrawRectangle(x,y,w,h)
function buttonclick()
--your code
end
addEventHandler("onClientGUIClick", button , buttonclick)