Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How can I change a GUI element's position to a pre-defined number using a script?

Asked by 9 years ago

Alright, looking for the way in which you change the position of a Gui element. Looking in the wiki provided no help. Aside from just changing, I want to change it to a pre-defined randomized number d1x.

d1x = math.random(1,50)

How can I change an X Offset value to d1x?

1 answer

Log in to vote
0
Answered by 9 years ago

You'll have to use UDim2.new()

UDim2.new() is formatted like so:

UDim2.new( XScale, XOffset, YScale, YOffset )

To set d1x as the X offset, you'll have to use UDim2.new() on the position of the GUI, like so:

local D1X = math.random(1, 50)
Gui.Position = UDim2.new(0, D1X, 0, 0)

Hope This Helped!

NOTE: You can also change the size of a Gui with UDim2.new()

0
Ah, thanks so much. The whole UDim2 lost me in the wiki. V6a6m6pyro 0 — 9y
0
Remember to like my answer please! TurboFusion 1821 — 9y
Ad

Answer this question