0 votes

I'm trying to print the health number onto the screen to tell the player how much health they have

Godot version 3.2.3
in Engine by (25 points)

1 Answer

0 votes

Use the str() function, like label.text = str(health)

by (7,190 points)

can you explain in more detail? I'm new to programming and don't know what that is

Okay what do you have right now so I know what to explain

i have a player, controls a health system and that's it. the variable name is Health. sorry if thats not what you mean.

Okay so you should use a Label node to display text. A label node has a text property that controls what text it displays. The str() function is a global function that converts anything into a string. You will need it to convert your health into a string. So, just call the str()function with your health and an argument and assign the value to the label's text.

how do I get the variable from the player script and allow the label node to use it?

I think you should read up on node paths. https://kidscancode.org/godot_recipes/basics/getting_nodes/

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 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 webmaster@godotengine.org with your username.