Forum Discussion
ThomasUmphres
10 months agoCommunity Member
Making Variables Round to Whole Number Rather Than to 2 Decimals
I have a pretty complex training I'm putting together using a lot of variables where numbers are being displayed with 1 or 2 decimal places. I want to force those numbers to show as rounded whole nu...
WaltHamilton
10 months agoSuper Hero
As of yet, it seems that you should stay away from ChatGPT, as you will probably have to train it. Here is a script that will work
var player = GetPlayer();
var numValue = player.GetVar("NumericEntry");
var JSRoundedNum = numValue.toFixed(2);
player.SetVar("RoundedNum",JSRoundedNum);
NumericEntry is the name of your variable in SL, and RoundedNum is the name of the Text variable that it will return. (JS doesn’t distinguish between text and numeric variables, so SL considers them as text.)