How To Add How Many Kills And How Many People Left In Godot

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

So, I Am Making A Battle Royale Game And I Dont Know How To Record How Many People Left And Kills So I Made This Post

So i Have A Label That Is Called (Counter Kills) And I Also Got (Counter Left) And They Are In The Enemy Mode Because I Have The Kill Script (When The Player Shoots The Enemy It Will Play An Animation And Die) I Want It To Add 1 Kill And 29 People Left But i Have Tried Many Ways But They Dont Work Any One Please Help

(Kill Script)
func kill():
dead = true
$CollisionShape.disabled = true“die”)

(Counter Kills Script)
var kills = 0

func _ready():
text = String(kills)

(Counter Left Script)
var left = 30

func _ready():
text = String(left)

These Are The Scripts That I Have

:bust_in_silhouette: Reply From: exuin

The problem is, there’s nothing in your scripts that are updating the counters. The values are only assigned at the start of the game. They’re always going to be 0 and 30. Try something like this:

Kill script

func kill():
    dead = true
    $CollisionShape.disabled = true"die")
    $CounterKills.kills += 1
    $CounterKills.text = str($CounterKills.kills)
    $CounterLeft.left -= 1
    $CounterLeft.text = str($CounterLeft.left)

thx I will Try

cochise123 | 2020-09-15 03:38

It Works But The Left Goes To 39 But It Is Meant To Go To 29 And The Kills Just Says P Also When I Kill Another Enemy It Just Stays The Same You Got Any Others Things That Will Work?

cochise123 | 2020-09-15 04:08

Can you give your entire script? I think I’m missing something here.

exuin | 2020-09-15 04:54

What Script? Or If You Want To Talk More Easier Add Me On Discord Year#2670

cochise123 | 2020-09-15 07:46

I’ve done so.

exuin | 2020-09-15 16:44