I’m trying to make a system that will make a TextLabel spawn at a set y point but a random x point.
I tried using math.random() like this, but this obviously yields an error. Since there must be a way to do this, as I have seen randomly generated ui on multiple occasions, I am thoroughly frustrated as to why I can’t crack this…
I tried making a seperate random number variable as shown above, and then plugging it in to the Udim to achieve a decimal, but that doesn’t work. Problem is, all Udim values are <= 1.
Udim also has a UDim2.fromOffset(x, y) and a UDim2.fromScale(x, y) constructors you can use. I’m guessing you want a random offset so you can just use it directly like this:
local numX = math.random(1, 9)
clone.Position = UDim2.fromOffset(numX, 0)
Divide the math.random by 10. For example, if it generates 4, dividing it by 10 converts it to 0.4. Or, if you have a number range of 1-100 you can divide by 100