Accessing a variable from js with c# script

I have a seperate scripts for player controller and inventory, in controller there’s a few variables like health and such which i need to add up or remove from inventory script. How is the appropriate way to do so? by getcomponent, thanks in advance.

This is caused by compilation order. I suggest you to take a look here :

Unity3D: JavaScript->C# or C#->JavaScript access
Special Folders and Script Compilation Order

Answer from here.

C# code is compiled before JS code, so
in general, while JS code can access
C# classes, the opposite is not
possible. However, you can affect the
order of compilation by moving scripts
into special folders which are
compiled earlier. You could move your
Test01JS script to a folder called
“Plugins” then it works.

And another great quote from here.

Only the scripts compiled last can
“see” the others.