I'm quite new to Godot and of all the tutorials, they all used GDScript, so I naturally gravitated towards it. I was making a simple textbox scene that writes out dialogue, following this tutorial -

However, I got this error when trying to run the scene: Invalid type in function 'interpolate_property' in base 'Tween'. Cannot convert argument 1 from String to Object.

This is my tree: https://i.imgur.com/xNT0KCo.png

This is the code: https://i.imgur.com/C6JEd5Q.png https://i.imgur.com/G4eQADs.png

(if the code doesn't show just copy and paste the URL, sorry it would give me a weird error) Thanks in advance.

You're assigning text to a Label node reference in the "onready var" declaration, but then you're assigning text to the string "" in func addText(). Is that a mistake?

@DaveTheCoder I changed all the var text references to var label for ease of editing, but nothing changes. The variable label (from now on) is supposed to be a string so that the text will show in the label.

Are you still getting the same error? What does the code look like now?

This error arises from the fact that your saying text = "". This is converting the Label to type String because you haven't statically declared the variable type. You should always use text.text when you want to change the actual content of the label, not just assign the whole object to an empty string. What you've told the editor to do is to convert the dynamic variable to a new string instead of representing the original object. You need to always use Label.text = "" if you want to change the text of the label without reassigning the variable to a different data type.

Here is my scene, I have a label named "stats".

In my script, I've statically typed the variable as type Label this ensures that I can't accidently reassign the variable to a different data type in the future. If I do the editor will give me an error. By saying text = "" instead of text.text="" you have essentially changed the data type of the variable to be an empty string, and it no longer represents the original node. That's why you keep getting "Invalid type in function 'interpolate_property' in base 'Tween'. Cannot convert argument 1 from String to Object." Because you've essentially converted the variable to a String. interpolate_property expects an Object as its first argument, not a String.

As you can see, if you just always use text.text = "" you will never get this problem.

As you'll notice in the video tutorial you provided, they specifically always use Label.text = "" for this exact reason, you can't do Label = "", that's just not how you access the text property of the label.

I suggest you check the official docs to get more information on dynamic and static variables in Godot: https://docs.godotengine.org/en/stable/getting_started/scripting/gdscript/gdscript_advanced.html

Thankssss! This worked well and I can use more stuff with this now.

@wavy said: Thankssss! This worked well and I can use more stuff with this now.

Glad I could help!

a year later