When i call set_text() in the label script, it creates a new label

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

Everytime i call set_text() for a label via global script, it creates a new label at 0,0. Its really frustrating bcs i am new to Godot and to me it should work. Maybe one of you could help me ^^

That should not happen. Can you post your code here? I don’t have enough information to help you.

exuin | 2021-09-13 17:13

I discribed it poorly. I meant if i create a function in a global script that set the text and i call that function in annother script it creates a new label. But anyway here is the code

  extends Label

var score = 0

func _on_Timer_timeout() -> void:

func _on_Score_tree_entered() -> void:
    score = 0

func update_score(addvalue):
    score += addvalue

And if i call update_score(1) in annother script it wont work :frowning:

Realdapi | 2021-09-13 19:03

I don’t see anything wrong with that code. What’s the global script like?

exuin | 2021-09-13 19:05

I set this script global
Bcs i want to change the set_text from another script with the update_text function

Realdapi | 2021-09-13 19:12

What’s the other script that you call this function from?

exuin | 2021-09-13 19:37

extends KinematicBody2D

var direction = Vector2.LEFT

func _physics_process(delta: float) -> void:
	var velocity = direction
	velocity.x = direction.x * 150
	move_and_slide(velocity, Vector2.UP)
	var collision = move_and_collide(velocity * delta)
	if collision:
		collision.collider.move_and_collide(velocity * delta)

func _on_VisibilityNotifier2D_screen_exited() -> void:

func _on_Jump_over_Checker_body_shape_entered(body_id: int, body: Node, body_shape: int, local_shape: int) -> void:
	if body.name == "Player":

it is for a enemy i call via preload

Realdapi | 2021-09-14 13:10

Im Stuck and frustrated. I really really Need help

Realdapi | 2021-09-15 20:49