lens studio script


I am trying to make one of those lens where it gives you a random percentage but I can't seem to get the script to appear on the screen. can anyone help or share the file of something similar they've made?



  • @pepps

    Show Random Percent % Script

    // -----JS CODE-----
    // For 3D Text only change Component.Text to Component.Text3D
    // Component.Text works for Both "Text Object" & "Screen Text"
    //@input Component.Text percentText
    if (script.percentText) {
    var randomPercent = Math.floor(Math.random() * 101); // generate a random integer between 0 and 100
    script.percentText.text = randomPercent.toString() + "%"; // format the value as a string with a percent sign

    Bookmark for Reference