This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
0 votes

Hello, I am new to Godot and I am making a game for my school project but I cannot get the score to update once I pick up a coin. but once the game ends it will then update how can I solve this?
I have checked multiple resources but none seem to work. Here is my code:

func _on_Area2D_body_entered(body):
if body.get_name() == "Floor":
PlayerVariable.Global_enemyScore += PlayerVariable.Global_enemyScore
var scoreCounter = print("The enemy's score is " + str(PlayerVariable.Global_enemyScore))
if body.get_name() == "Player":
PlayerVariable.Global_playerScore += PlayerVariable.Global_playerScore
("The player's score is: " + str(PlayerVariable.Global_playerScore))
PlayerVariable.Global_totalScore = PlayerVariable.Global_playerScore


Also here is my node layout:


Can you help?

in Engine by (18 points)

Can you repost your code with tabs please, so it's spaced out as it would be in the editor?

Please log in or register to answer this question.

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.