I am trying to make this script change the BackgroundTransparency
of a frame to a random number between 0.1 to 0.9 but it ends up setting it as 0. Can anyone tell me how to make this work besides having to do.
if math == 1 then script.Parent.BackgroundTransparency = 0.1 end
Here is the script:
local math = math.random(1,9) script.Parent.BackgroundTransparency = 0.,math
just divide the number by 10!
script.Parent.BackgroundTransparency = math.random(1,9)/10 -- will generate a number between 0.1 and 0.9
Note: You should never overwrite standard roblox variables like math
, pick a different variable name
You need to set the BackgroundTransparency to your variable on line 1 divided by 10!
local random = math.random(1,9) --rename your variable script.Parent.BackgroundTransparency = random/10