Hi so how Would I be able to make an kill counter

Godot Version



How would I be able to make a kill counter in an multiplayer game, But it shows up at the screen of the person that died

at the moment I do this

func receive_damage():
	health -= 10
	if health <= 0:
                kills += 1
		health = 200
		position = Vector3(0.0, 0.0, 0.1)
and then

label.text = "kill counter: "+str(kills)```

Seems like you need to add who dealth the damage to the function, or return if they died.

func receive_damage(attacker: Player) -> bool:
    var killed: bool = false
    health -= 10
    if health <= 0:
         attacker.kills += 1
         killed = true
    return killed

hi so after I implemented this, it is giving me an error:

 _process_rpc: RPC - 'CharacterBody3D::receive_damage': Method expected 1 arguments, but called with 

Right you need to supply the attacker to your function call.

it might look something like this

# where `body` is the player being attacked

so I my case something like this

1 Like