0 votes

I tried the following but it does not work:
func process(delta):
for child in $GridContainer.get
children():
child.name.text = "New Text"

I get Error:
Invalid set index 'text' (on base: 'String') with value of type 'String'.

Godot version 3.5.1
in Engine by (42 points)

1 Answer

+1 vote
Best answer

For future, you're probably best off keeping this kind of conversation in the original question, but at least you've referenced it here...

Your problem is that both name and text are individual properties of a button. To change the text, you just want this:

child.text = "New text"
by (21,692 points)
selected by

thanks jgodfrey for your help. one more question
if I want to access customstyles/normal of the button how do I do it?
I tried
child.set("custom
styles/normal",Color.firebrick)
and
child["customstyles/normal"].bgcolor = Color("#bada55")
but they dont work not sure why?

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.