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

Changes background transparency to 0 instead of 0.1 - 0.9?

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

2 answers

✓ Accepted answer

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

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