score in godot

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By CB

I need a help.

I can not show the score in my game
I dont get to use signal it’s more confuse to me.

extends Node # main node of my game
var score = 0

func _ready():
$player.connect(“coin_taken”, self, “_on_coin_was_taken”)

func _process(delta):

func on_coin_was_taken():

score = score + 1

$HUD/display/coin_anim/coins.text = score
print (score)

extends Area2D #this is the coin item

signal coin_taken

func _on_moeda_body_entered(body):

if "player" in	

nothing happens!
I don’t know where I’m mistaking

:bust_in_silhouette: Reply From: LordViperion

Possible you writed wrong something.
func ready():
$player.connect(“cointaken”, self, “oncoinwastaken”)

Try to change for:

func ready():
$player.connect("coin_taken", self, "oncoinwas_taken")

I tried this way:

var coin_count = int(0)
onready var score_count = $“HUD/display/coin_anim/coin”

func on_coin_taken():
coin_count += 1
score_count.set(“text”, str(coin_count))

coin_hit  = false

an error is shown:
Attempt to call function ‘set’ in base ‘null instance’ on a null instance.

when I put #
print shows correctly the amount of coins collected

CB | 2019-02-03 16:35