(function() { var _this; var ogPos = {x:0,y:0.7,z:0}; function MyObject() { // Can be used a constructor, define all the // variables in here instead of below where they are shared among all the instances of the entity print("Rave Time"); } MyObject.prototype = { preload: function(_entityID) { this.entityID = _entityID; _this = this; //ogPos = Entities.getEntityProperties(_this.entityID).localPosition; } } Script.update.connect(update); function update(){ var color; //print(JSON.stringify(ogPos)); Entities.editEntity(_this.entityID, { "color": { "red": Math.floor(Math.random()*3)*128, "green": Math.floor(Math.random()*3)*128, "blue": Math.floor(Math.random()*3)*128 } }); } function onEnding() { Script.update.disconnect(update); } Script.scriptEnding.connect(onEnding);w return new MyObject(); })