0 votes

Hello everybody, i have made a counter that displays the money but i notices another counter that appears at the top left of my screen
The label script

extends Label

func _process(_delta):
    text = String(Global.coins)

the coins is a global variable and i have made a script for it

script for the global variable coins

extends Node

var coins = 0

when i play the game another label is created in the spatial
i haven't got a code that creates another node in the spatial

so, what could go wrong with it?
I am sure the problem comes with that self created label but i don't know from where it's made

in Engine by (68 points)

Mabey you have code somewhere else making the number?

Mind sharing your scene tree?

1 Answer

+1 vote

From another forum they told me my mistake was that i have dMoney once as a Singleton and once as a node/instance in your level hierarchy. Either i should remove the dMoney node from my scene or remove it from the AutoLoad(Singletons) tab.

Every Singleton gets loaded once and persists throughout the whole game. Note that in the Remotes list the coins and Global are directly parented to the root Viewport of the game.

https://godotforums.org/discussion/22301/i-have-a-counter-that-displays-the-nuber-of-money-but-another-counter-appears-too#latest

by (68 points)

Thank you for sharing your answer, even if it came from somewhere else.

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.