The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates.

godotengine.org | Twitter

0 votes

I'm trying to convert a memory game into a Guess Who style game.

I'm trying to call two variables (face and back) from one script, Card.

(Card.gd)

extends TextureButton

class_name Card

var face
var back

(GameManager.gd)

extends Node

var f = Card.face
var b = Card.back

When I run the game to test it, the error in the title pops up, both for 'face' and 'back'.

Does anyone know how to fix it?

Godot version Godot v.3.4.5
in Engine by (17 points)

1 Answer

0 votes
Best answer

You are trying to use Card as a singleton/autoload. You need to use an instanced Card object instead:

# GameManager.gd
extends Node

func something():
    ...
    # Get a node that inherits `Card` from the scene tree
    var my_card = $MyCard
    var f = my_card.face
    var b = my_card.back
by (286 points)
selected by
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.