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

Math.random doesn't work with updating a GUI position?

I am trying to update a guis position with math.random and it dosent work, just does the same position every time. Here's my script:

local Numbers = math.random(0.2,0.8)
script.Parent.Position = (UDim2.new(Numbers, 0, 0.8, 0))
script.Parent:TweenPosition(UDim2.new(Numbers,0,0.8),"In","Linear",1,true)
wait(0.1)
for i = 1,20 do
	script.Parent.Text.TextStrokeTransparency = script.Parent.Text.TextStrokeTransparency +0.05
	script.Parent.Text.TextTransparency = script.Parent.Text.TextTransparency +0.05
	script.Parent.ImageTransparency = script.Parent.ImageTransparency + 0.05
	wait(0.05)
end	
script.Parent:Destroy()

Idk whats wrong here.

2 comments

0

Is the "local Numbers = math.random(0.2,0.8)" in some type of loop or is it being called every time it's used. If you have nothing to reset the math.random the numbers will stay the same from the first time it picked them

0

Don't forget to accept my answer if it helps out.

1 answer

✓ Accepted answer

The fractional part of the number you passed to random is discarded.

• math.random() generates numbers in the interval [0, 1) (so it can generate 0 up to 0.999999 but never 1)

• math.random(min, max) generates integer in the interval [min, max]

• math.random(max) generates integer in the interval [1, max]

If you want to get a percentage, then use math.random() or math.random(min, max)/max.

local number = math.random(10)/10 -- # example

1 comment

0

This is confusing

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