Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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.

1 comment

0

just use math.random() without any arguments for a decimal value between 0 and 1

1 answer

✓ Accepted answer

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.

This discussion is preserved as it was. New answers, comments, and votes are closed.