I am trying to change the text of a Richtextlabel from a different script using a setter and adding to that variable but when I do it, the function is called and the value changes but the label doesn't visually update.
Money_text script:
`extends RichTextLabel
var money: int:
set(value):
money = value
display_text()
func _ready():
money = 2000
func display_text():
self.text = str(money)`
Color_rect script:
`extends ColorRect
func _on_button_pressed():
MoneyText.money += 20
print(MoneyText.get_text())`
And the function above is connected to a button. The result is, when the button is pressed, the label is initially declared to be 2000 from _ready(). The output is 2010 and keeps going up when the button is pressed more. I've tried set_text(), get_text() which does the same as the output, calling a different function that adds a variable to money, etc and it all doesn't work. The only thing that works is using:
`func _unhandled_input(event):
if event is InputEventKey:
if event.pressed and event.keycode == KEY_A:
money += 20
Where "KEY_A" can be any key. This only works if the function is attached to Money_text.