You weren't playing?
Weren't you playing?
Or could it be written in both ways? My teacher gave me the first question but I don't know. It doesn't look grammatically correct. Thanks in advance
This answer is a bit convoluted.
"Weren't you playing" is the standard way to ask that question in English. That part of the answer is not at all convoluted.
However, at least in modern American SPEECH, particularly informal speech, questions in the form of "You weren't playing" are sometimes asked by altering the pitch of the verb. Consequently, there may be instances of someone trying to indicate such a locution in writing with "You weren't playing?" The question mark would attempt to take the place of the change in pitch.
I recommend that you stick with the standard form because you will never be misunderstood. And even if, contrary to my recommendation, you do not always use the standard form in speech, absolutely stick with the standard form in any kind of formal writing.