GUI Positions
First, ignore screens. Just think rectangles.
Any rectangle has a width and a height.
If we're measuring the width and height, in, say, pixels, We call the top-left (0, 0) and the bottom-right (width, height).
Then the center will be half way in between: (width/2, height/2).
If we were to squash the box so it was now flatter, the (oldwidth/2, oldheight/2) will not be the center of the new box. Further more, (0, height) is now way past the bottom-left.
So this scheme isn't going to do well to keep track of things like centers or edges.
Let's measure points on the box in scale -- we call (0, 0) the top-left, still, but the bottom-right will be (1, 1). Then the middle is (0.5, 0.5), no matter what size the rectangle is.
ROBLOX uses a value called UDim2 which combines these two measurements: Scale and Offset (in "pixels"[^1]) -- you add the two components.
[^1]: Not hardware pixels -- on high-dpi phones, 1 offset corresponds to more than one hardware pixel
Events
Chunks of scripts are always executed from top to bottom. But there are a few kinds of flow control in addition to functions which "skip" around. There are also multiple coroutines which can be "executing" in different places in the same script.
Functions
When Lua passes by a function definition, e.g.
print("first")
function blah()
print("second")
end
print("third")
The inside of the function does not run -- it simply defines what to do when the function blah is called.
Later, when we call blah, Lua remember where blah is and jumps back to the inside of blah (temporarily).
That's what happens with events -- you give ROBLOX a function, and ROBLOX then knows where to jump into when an event happens.
3
It depends. In general, one script will perform a little better, and will often be a little cleaner (though a bit longer).
The main reason it performs better is because many while wait() dos (or similar constructs) will compete with one another if they're in separate scripts. There starts to be a lot of time taken just to hand off between the scripts. If there's only one, then that's much less of a problem.
4 comments
Thanks so much! I figured there was something that made those first values useful, never figured it out though!
Glad I could help!
Scale is a percentage (in decimal form), just like Transparency or Reflectance. Therefore, just use a number between 0 and 1.
^ Yep! If you get into more advanced GUI work, you may go over 1, for nice animations.