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

Is it possible to call NumberValues when using math.random?

Asked by 4 years ago
Edited 4 years ago
local ReL1 = script.Parent.RegularNumber.SurfaceGui.TextLabel
local Rel2 = script.Parent.RegularNumber1.SurfaceGui.TextLabel
local PrL1 = script.Parent.PremiumNumber.SurfaceGui.TextLabel
local PrL2 = script.Parent.PremiumNumber1.SurfaceGui.TextLabel
local DiL1 = script.Parent.DieselNumber.SurfaceGui.TextLabel
local DiL2 = script.Parent.DieselNumber1.SurfaceGui.TextLabel
local RL = script.Parent.Configuration.RegLow
local RR = script.Parent.Configuration.RegHigh
local PL = script.Parent.Configuration.PreLow
local PH = script.Parent.Configuration.PreHigh
local DL = script.Parent.Configuration.DisLow
local DH = script.Parent.Configuration.DisHigh

while true do
    wait(math.random(.1,1))
    ReL1.Text = math.random(RL, RR)


end

Is it possible to use NumberValues for random()??? this script currently does not work because of that.

0
just use math.random() without any arguments for a decimal value between 0 and 1 theking48989987 2147 — 4y

1 answer

Log in to vote
0
Answered by
oreoollie 649 Moderation Voter
4 years ago
Edited 4 years ago

It seems to me that your feeding math.random(m, n) non-integer arguments, but it only accepts integer arguments. A work around would be to multiply the gas highs and lows by 100 (assuming there's only two decimal places), feed it into the generator then divide the output by 100. Here's an example of that code.

local ReL1 = script.Parent.RegularNumber.SurfaceGui.TextLabel
local Rel2 = script.Parent.RegularNumber1.SurfaceGui.TextLabel
local PrL1 = script.Parent.PremiumNumber.SurfaceGui.TextLabel
local PrL2 = script.Parent.PremiumNumber1.SurfaceGui.TextLabel
local DiL1 = script.Parent.DieselNumber.SurfaceGui.TextLabel
local DiL2 = script.Parent.DieselNumber1.SurfaceGui.TextLabel
local RL = script.Parent.Configuration.RegLow
local RR = script.Parent.Configuration.RegHigh
local PL = script.Parent.Configuration.PreLow
local PH = script.Parent.Configuration.PreHigh
local DL = script.Parent.Configuration.DisLow
local DH = script.Parent.Configuration.DisHigh

while true do
    wait(math.random(0,1))
    ReL1.Text = (math.random(RL*100, RR*100))/100
end

If my answer solved your problem please don't forget to accept it. It helps me out a lot.

Ad

Answer this question