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

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

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

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()

2 comments

0

Ah, thanks so much. The whole UDim2 lost me in the wiki.

0

Remember to like my answer please!

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