Syntax error: start "string" near 'then"

10/27/2013 07:47 poXavincS#1
Hi guys I am create a basic quest with use to item click. After is quest working but, I am complex to quest loop, show me this is error,

syntax error : [string "start"]:108: unexpected symbol near `then"

My quest line between 99 and 119 is;

PHP Code:
local _gold select("500M","1T","Close")
if 
_gold == 1 then
     say_title
("MyMT2 - 500M Buy")
     
say("")
     if 
pc.get_gold() <= 500000000 then
         say
("You haven't enough money!")
         
local k select("Close")
     else
         
pc.change_money(-500000000)
         
pc.give_item(3,1)
     
end
elseif _gold == 2 then
     say_title
("MyMT2 - 1T Buy")
     
say("")
     if 
pc.get_gold() <= 1000000000 then
         say
("You haven't enough money!")
         if 
pc.count_item(3) == 0 then
             say
("And, you haven't 500M item as money!")
         
end
         say
("Just, You have "..pc.count_item(3).." piece 500M item as money.")
         
local k select("Close"
Thank you for interest!

Good works..