When I type export before my var, the variable does not appear in the script variables section under the inspector tab

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

I’m relatively new to Godot engine and coding in general. I was watching a tutorial on how to make a Platformer for beginners, and when the instructor typed export before var, their variable would appear in a new section under the inspector tab called “Script Variables”. However, when I do the same, the Script Variables section does not appear. I am very confused. The video was made in October of last year.

:bust_in_silhouette: Reply From: bruteforce

I can only guess, post your code!

From the docs:

An exported variable must be initialized to a constant expression or have an export hint in the form of an argument to the export keyword…

For example, these are valid export var. declarations:

export var a = 10;
export(int) var b = 10;

And this is not:

export var c;

Is there any syntax error in your code (anywhere)? It can also ruin things… the script parser may get stucked.

Edit: the hint was in the wrong place… fixed

For me it helped to add the export hint. export(bool) var test = false would show, while export var test = false would not.

mrimvo | 2021-04-19 10:43

:bust_in_silhouette: Reply From: ballerburg9005

Although it doesn’t answer your question, generally speaking it is probably better to use Metadata Inspector. It allows you to create node-specific variables directly from the UI that you can use in scripts.

Exporting variables from scripts strictly speaking only makes truly sense if the variable is just a script-specific parameter (such as specifying “speed” for a scroller).

In most cases though, variables are node-specific, that is either instance or prototype-specific data elements that belong to logical objects (such as crests, creatures, trees) that store mutable properties and can be affected by a lot of different logic in the game. Logic that again belongs to many other logical objects and processes.

Metadata is exactly suited for this and with Metadata Inspector you can easily create it.

You can download Metadata Inspector from the Godot AssetLib.

Metadata Inspector

If you’re promoting your own tools, be at least so fair to point out that you’re their creator, thus potentially biased when it comes to their usefulness. Personally I don’t see any real advantage of using “metadata inspector” over export variables other than that you apparently don’t need to attach a script (which is really a non-issue for me).

njamster | 2020-07-16 17:36

:bust_in_silhouette: Reply From: TheLoneBit

I know this is a bit late… but if you are doing the same tutorial I think you are doing, from GDQuest. The solution to this is that it is a bug that can only be fixed by reloading the project. After you reload the project after the first initial setup any Exports you add afterward will show up. Weird bug. I don’t know why or how it happens. That is the only solution I know of.

this is true after reload it is fixed.thank you!

jasithpramudaya | 2021-02-14 18:44

Dude I created an account just to say thank you!

AtoMMonster | 2021-03-13 16:44

Maybe you can help me out I had this issue I closed the program and reopened it and my exported variables still don’t show up I’m doing the same tutorial

Rosieisuposie | 2021-04-14 06:26

hello, i found a solution for the same problem.
I discovered that, i don’t know why, the icon of the script for “Player” in the scene window had disappeared. I just create a new script for it, clicking on the “new script” button, and the “script variables” finally appear.
Tell me if you had the same issue, and if it is now fixed.

Gregory Watine | 2021-06-15 15:17

this worked thanks dude

destroyer | 2021-08-14 15:42

:bust_in_silhouette: Reply From: KhalidOwlWalid

I had the same issue, I have already export it and it works just fine initially but suddenly, the export variable does not shop up in my Inspector tab.

Apparently, the gd script attached to it was somehow removed. What I did was basically, go to my “player” node and in the inspector tab, in the Script section, I added my script file again.

:bust_in_silhouette: Reply From: Mercutio_x

I presume that you are doing the GDQuest Tuto; delete then rewrite " extends Actor ".

This worked. Thanks!

rontondelta | 2022-04-07 00:23

Restarting the project worked for me as well. Although my problem was that I was adding [Export] after I renamed the C# script. Turns out the script reference in the tscn file wasn’t changed automatically.

1 Like

Hi i have the same error, and if you use Godo > 4 do you need to write:
export var story = “”
@export var story = “”
only add the @ key.
I hope this helps