Ok a better way is to just use an array having the limits and scale format. Also do not call _ready() as a function. Normally they are called by events.
E.g.
extends Button
var preco = 100
var level = 0
var valor
var scale
signal comprou
func _process(_delta):
pass
func _ready():
scale=0
valor = [[1,"%10.0f"],[1000.0,"%10.2fK"],[1e6,"%10.2fM"],[1e9,"%10.2fB"],[1e12,"%10.2fT"]]
format()
pass
func format():
var prcf
# check if price reached next scale
if preco>=valor[scale+1][0]:
prcf=preco/valor[scale+1][0]
scale+=1
else:
prcf=preco/valor[scale][0]
text = valor[scale][1] % [prcf]
func _on_CoinBar_compra_efetuada_power():
preco = preco * 1.5
level = level + 1
format()