Sign In Register

How can we help you today?

Start a new topic

Set ScriptData value to a JSON

I know how to set singular values into scriptData, but I think this is tedious as I'd rather pull a JSON of several values at once instead of grabbing single values 6 times.

    var mainData = Spark.getData().scriptData.regInfo;

"RegInfo" is the JSON I'm submitting

 Spark.getPlayer().setScriptData("mainData", mainData);

What results is the JSON appears under ScriptData, however when it's unfolded, it has no values, which means it is detecting it's a JSON but it won't treat it like one. How can I make it detect all the values inside?

I ended up having to do it this way- just taking the individual values and making them into a JSON on my end. This is fine for now because these are all the values I need to put into scriptData.

However as far as my runtimeCollections go, I need to save much larger classes.


 var email = Spark.getData();
         var age = Spark.getData().scriptData.age;
          var birthday = Spark.getData().scriptData.birthday;
          var pClass = Spark.getData().scriptData.pClass;
          var times = Spark.getData().scriptData.times;
          var iden = Spark.getData().scriptData.iden;
          var goodnoodle = Spark.getData().scriptData.goodnoodle;
          var or = Spark.getData().scriptData.or;
          var suspended = Spark.getData().scriptData.suspended;
          var susptime = Spark.getData().scriptData.susptime;
          var susptimebeginhour = Spark.getData().scriptData.susptimebeginhour;
          var susptimebeginday = Spark.getData().scriptData.susptimebeginday;
          var banned = Spark.getData().scriptData.banned;
          var reas = Spark.getData().scriptData.reason;
          var staff = Spark.getData().scriptData.staff;
                  var mainData ={


I'm hoping this tutorial

Will help with that, although I also have arrays of ints/floats inside of my regular classes as well. I'm hoping that this is a working solution out of the box.

As long as it's valid json you should be able to insert it into your runtime collection. I would recommend that you reduce all of your 'Spark.getData()' calls into a single call though:

var scriptData = Spark.getData().scriptData;

var email =;

var age = scriptData.age;

or, if these vars aren't being used elsewhere in the script you can skip assigning the values to variables altogether:

var scriptData = Spark.getData().scriptData;

var mainData = {







I've been unable to reproduce this behaviour. Setting objects to a player's script data is working as expected for me. Could you try the following:

- Hard-coding an object and setting it the player's scriptData, see if you're getting the same result

- Logging the value of Spark.getData().scriptData.regInfo prior to setting it to scriptData to ensure it is being retrieved correctly.



Login to post a comment