Variable from public class to script

Stuck trying to access variable “speed” from the below script…

I have a C script called Blackx.cs with

public class Blackx : MonoBehaviour {

public float speed = 16;

I’m trying to access that speed value using a test.js script attached to the same object, but nothing works…

What is the correct syntax please?

Your problem is that you can’t just have javascript and C# access each other unfortunately - this is because they are compiled into different DLLs.

If you want the C# to access the JS then the JS needs to be in one of the early compiled folders like Plugins, Standard Assets etc.

Generally it is not a good idea to have JS and C# access each other in your main game - it just leads to problems like this - and it gets worse as you can never do it both ways.