Cannot implicitly convert type `void' to `float'

Hello there…

I’m trying to obtain a variable from one JS scripy to a C# one… I’ve the following code for that:

float Speed = print(PlayerScript.Speed);
string speedstring = Convert.ToString(Speed);

The objective is to show the value in a GUI.Label, but the Speed variable from the JS script is returning has void… So, how to make it return as a float?

Thanks for the answer…

There are several problems here.

First, print(value) doesn’t return a float- it doesn’t return anything! Why are you trying to get a value out of that? It’s possible that you are getting confused here. Try splitting it into two lines-

float speed = PlayerScript.Speed;
Debug.Log(speed);

Second, I need to see more of your code to really understand what you’re trying to do here. Remember that it’s hard to get scripts in JS and C# to talk to each-other- it’s usually easiest to just use either one language, or the other. If you have found scripts on the internet that you want to incorporate which use the wrong language, it might be worth your while to learn how to convert between them.