Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to set a 0. before a number? [Answered]

Asked by
Bertox 159
8 years ago

I have a NumberValue, it's like 10. How to make another value, wich is making the 10 to 0.10 with can be used on Properties values. i tried this:

Speed = 10
Speed2 = "0." ..Speed
Sound.Volume = Speed2

But it isn't working.

0
No, it dosn't work Bertox 159 — 8y
0
You can press the Accept Answer button. Do yourself a favour. User#6546 35 — 8y

2 answers

Log in to vote
2
Answered by 8 years ago

Divide

Surely you know how to divide. To make a number scaling from 0 to 100 into a decimal, which I assume is what you're doing given the context, just divide it by 100.

Speed = 10
Speed2 = Speed/100
Sound.Volume = Speed2
Ad
Log in to vote
0
Answered by 8 years ago

You're attempting to concatenate Speed with a string, which will then convert the value of Speed to a string inside of the variable, making Speed2 equal to the PHRASE "0.10", but not the value 0.10. The following code should fix your problem.

Speed = "10"
Speed2 = "0." .. Speed
Speed3 = tonumber(Speed2)

Sound.Volume = Speed3
0
0.1 is not an integer 1waffle1 2908 — 8y

Answer this question