Hi! I am completely newbie to Godot and all coding stuff. I want to create some kind of instant teleportation of character from it's position to another like that: when I click mouse on button (it has Area with Signal script) character should instantly change his position to position of other object ("portal_2" unseen for player).
I use Godot 4. I tried to script this but can't understand how to make it. My last attempt of Signal script looks so:

extends MeshInstance3D

@onready var character = get_parent().get_node("char_body")
@onready var portal_2 = get_node("portal_2")

var char_position = character.get_position()
var portal_2_pos = portal_2.get_position()

func _on_area_3d_input_event(camera, event, position, normal, shape_idx):
	if event is InputEventMouseButton:
		if event.button_index == MOUSE_BUTTON_LEFT and event.pressed == true:
			char_position = portal_2_pos

Please, explain someone. what are my mistakes and how to do what I want.

    Ulfr_Hrafnungr char_position = portal_2_pos

    That's only changing a local variable. To change the character's position:
    character.position = portal_2_pos

    There may be other issues, but that mistake is obvious.

      DaveTheCoder thanks. But it seems that there is another problems.
      When I try to execute scene, I get error "Invalid call. Nonexistent function 'get_position' in base 'Nil'". on this line:

      var char_position = character.get_position()

      I suppose that something wrong with "@onready var character = get_parent().get_node("char_body")". Here I try to get mesh of my character that is child object of root scene, but this script is attached to Area that is child object of mesh "portal_2". I'am not sure if engine can correctly call "char_body" in that case. 🙁

      The answer depends on the scene tree. You can print it by adding this to that script:

      func _ready() -> void:
          get_tree().get_root().print_tree()