+1 vote
extends ConfirmationDialog

var character = preload("res://Player.tscn")

signal redrawheroname()

func _on_ConfirmationDialog_confirmed():
    var newName = $LineEdit.text
    character.name = newName

Does anyone know how to do this? This is my code but it's not working.

in Engine by (308 points)

We're going to need more info. What doesn't work exactly? What is the behaviour you expect?

What I see:

  • you have a signal redrawheroname, but you're not doing anything with it.
  • you are assigning the new text to the name property of a PackedScene object. You are not instancing your character, you are just preloading the scene. In order to add your PackedScene to the game, you must call .instance() on it and then add the instance as a child to a node in the scene.
  • you really really should follow the official tutorials. They are well written and easy to follow, andyou wouldn't struggle with the basics. I really recommend them, that's how I started: https://docs.godotengine.org/en/stable/getting_started/step_by_step/your_first_game.html#spawning-mobs (scroll down and you'll see an example where they spawn mobs from a preload scene)

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.