http://www.lua.org/manual/5.1/manual.html#pdf-tonumber
You don't want to change the base parameter but string.gsub returns 2 values. One being the substring and the other the place (integer) at which the sub string starts. Both of these values are passed to your tonumber and it causes the error. Why? Because your base will be 1 (where $ is found), but you can't pass a value smaller than 2 and larger than 35.
If you expect $ to be anywhere else than at start then you want to assign the first returned value from string.gsub to a variable and pass it to tonumber later but if you expect the $ to be as the first character then you can use this method instead:
tonumber( string.sub( "$900", 2, -1 ) )