You can create instances by using Instance.new()
local screengui = Instance.new("ScreenGui",game:GetService("StarterGui"))
local frame = Instance.new("Frame",screengui)
Now let's change up the object's names.
screengui.Name = "ExampleGUI"
frame.Name = "ExampleFrame"
Now that we have a ScreenGui and a Frame, let's change their size.
UI Objects' size and position are a UDim2 value.
You would type UDim2.new(), and type in the size/position just like you would in it's properties.
For the sake of this demo, I'm just going to put the frame to cover half of the screen.
frame.Size = UDim2.new(0.5,0,0.5,0)
Now let's change the position.
Again, this will also be a UDim2 value. So you do the same thing as you did for the size.
For the sake of this demo. I'm just going put the frame in the middle of the screen.
frame.Position = UDim2.new(0.25,0,0.25,0)
And, there you go.
You now have a ScreenGui and a Frame.
If you enjoyed this tutorial, please accept the answer, so both of us can gain reputation! :)
1 comment
http://xyproblem.info