Please format your code for readability. You can use Ctrl + E, the preformatted text button
, or manually do it:
```gd
# Paste your code here
```
So it looks like this:
# Paste your code here
Now it is clearer to me what you’re doing, which is making a launch button.
Consider using a Resource class to represent your character classes. Then add that as a variable to the Player.
You can only have one script per Node, but you can have many Nodes per Scene. If you are asking this question, I recommend taking a step back and doing a few tutorials before you jump in head first. Learning how Godot works will save you a lot of time. This tutorial will show you how to create a 2D character: Your first 2D game — Godot Engine (stable) documentation in English
Then you can learn how to add a Resource. Here’s an example using typical D&D stats:
class_name CharacterClass extends Resource
@export var name: String
@export var icon: Texture2D
@export var hit_die: int = 8
@export_category("Attributes")
@export var strength: int = 10
@export var dexterity: int = 10
@export var constitution: int = 10
@export var intelligence: int = 10
@export var wisdom: int = 10
@export var charisma: int = 10
Then you can create a version for each class. You’d have a monk.tres.
You’ll need a place to pass that information along, so create a Game Autoload.
extends Node
var selected_class: CharacterClass
Attach it to a Node called Game, then add that scene as an Autoload. (See the previous link to see how.)
Then create a button for each class. A single script that is customizable.
class_name ClassButton extends Button
@export character_class: CharacterClass
func _ready() -> void:
pressed.connect(_on_button_pressed)
func _on_button_pressed() -> void:
get_tree().change_scene_to_file(“res://gameplay/world/test_world.tscn”)
Game.selected_class = character_class