Some corrections to get you started, provided the indentation is correct.
def encrypted_message():
## "message" has not been defined in this function
char = message
encrypted_message = ""
## encrypted_message = "" from the previous statement
for char in encrypted_message:
x = ord(char)
if char.isalpha():
## "key" has not been declared yet
x = x + key
offset = 65
if char.islower():
offset = 97
## if char is not alpha, then offset has not been defined
while x < offset:
x += 26
while x > offset+25:
x -= 26
## key is being added to x twice, once in statement #11 and once here
encrypted_message += chr(x+key)
print encrypted_message