I need some help with JavaScript

Hello! I have a little JavaScript code that shuffles an array and picks the first 2 values of it. Here it is.

I want to do the same thing in GDevelop, but I don’t how to to make the result appear in a textbox.

I tried this

but it shows this

Can you show me how to do it correctly?

I think it’s pretty obvious that I have no idea about JavaScript, especially when it comes to GDevelop. I’m trying to learn it. Also, I hope you understand my problem, my english is not that good.

The array tools extension allow to shuffle an array easily through events, try to use it instead of JavaScript code.

You can access the scene variables and update the values from JS:

runtimeScene.getVariables().get(“sceneVarName”).setNumber(XXX);
runtimeScene.getVariables().get(“sceneVarName”).setString(“XXXX”);

Hello luxako, You have declared the variables and assigned them before calculating their value. Place your two lines runtimeScene.getVariables() at the end of the code. I think you should be satisfied with this.
Best regards. Alexandre

@APardaillan I tried it and it worked! Thank you so much!

Also, @steliosm your username is Greek. Are you from Greece?

Hello, i’m not greek, i am French man. Have a nice day. Alexandre

Yes, indeed, I’m from Greece.