Getting a variable from a different script

Godot Version

4.2.1

Question

I’m following a tutorial trying to learn Godot so if this seems like a weird thing to do, this is why. The tutorial is also using GDscript while I am coding in C#.
I created a node and a new exported property called file_path:[Export(PropertyHint.File,“*.tscn”)] public string file_path {get; set;}

I am trying to access this property in a different script using body.file_path.
image

I however get this error: ‘Node’ does not contain a definition for ‘file_path’ and no accessible extension method ‘file_path’ accepting a first argument of type ‘Node’ could be found (are you missing a using directive or an assembly reference?)

What am I doing wrong?

Check if body is the node you think it is.

It is. I printed out the name of the body to the console and it recognises it as the correct node.

Your body reference (can’t tell where it’s coming from, given the lack of context in the initial post) is typed as a Node, but the object has a more concrete type it could be cast as. This is the same answer as:

Thanks, I’ll try this. Is there no way to do it more generically though? As in not not writing the name of the class I want it to be but rather cycling through all groups that contain “Goal” and casting as the one it encountered

It is quite hard to know what you are going for from the line and a half of code we have as context. I imagine you could use interfaces to solve your problem, from what I gather.