+1 vote

I have a Node attached with the following script:

using Godot;
using System;

public class Stats : Node
    public int max_health = 1;

The script is defined as C# but anytime that I try to run the game I get in the MSBuild tab:

Stats.cs(6,5): Preprocessor directive expected

So, I get an error in the #Export declaration, I have been using C# in this project without any problem which is why this is unexpected.
So, can someone please help me with this? I'm on Linux also.

Godot version 3.3.2
in Engine by (16 points)

1 Answer

0 votes
Best answer

You need to remove the # in #[Export], so it looks like this: [Export].

# in C# is used to declare preprocessor directives, hence the error message says that it expects such a directive.

by (1,147 points)
selected by

Thank you, I really was stuck with this.

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 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 webmaster@godotengine.org with your username.