User:Blocco/RbxGui
As with many of the current Libraries, RbxGui is a Lua Asset designed to assist with the making of GUI widgets. This article will explain to you what RbxGui is, how to use it and how to keep up with its ever-changing API.
What is RbxGui?
RbxGui is (as stated above) an official Roblox-created library specifically for aiding with the creation of GUI programs. Its use is not mandatory, but is recommended for those who would like to make good looking GUI features in lesser amounts of time.
How do I use RbxGui?
RbxGui is used by simply loading the library in your code and storing it in a variable. After that, one can easily use the various API functions and methods that the library has to offer. Below is some sample code that demonstrates the use of this library.
Note: This library uses fields instead of methods, so don't use a colon. Use a period instead.
function waitForChild(p, c) -- utility code; don't worry about this while not p:FindFirstChild(c) do p.ChildAdded:wait(); end return p[c]; end local library=LoadRobloxLibrary("RbxGui") -- load our "RbxGui" library function onItemSelected(item) -- create our callback that gets called when an item gets selected -- arguments: item (string) print("'" .. item .. "' was selected!"); end local listOfItems={"This", "is", "a", "list", "of", "items."}; -- our list of items local dropDownList, updateSelection=library.CreateDropDownMenu(listOfItems, onItemSelected); -- create the drop down list with our list and the callback dropDownList.Size = UDim2.new(1, 0, 1, 0) -- this is to make the drop down list fit in our GUI correctly local holderGui = Instance.new("ScreenGui"); -- make the screen gui that holds everything local holderFrame = Instance.new("Frame"); -- make a frame to hold the drop down list holderFrame.Size = UDim2.new(0, 200, 0, 26); -- make it the size you want holderFrame.Position = UDim2.new(0.5, -100, 0.5, -20); -- position it the way you want (right now it's in the center) holderFrame.BackgroundTransparency = 1; -- make it transparent for the drop down list holderFrame.Parent = holderGui; dropDownList.Parent = holderFrame; -- put the drop down list in the frame if game.Players.LocalPlayer then -- make sure we have a player local playerGui = waitForChild(game.Players.LocalPlayer, "PlayerGui"); -- wait for playergui holderGui.Parent = playerGui; -- put the screen gui in the playergui end
How do you figure out what's in this library?
To find all of the values in a library, you have to use a method found in every library, called GetApi. This method allows you to see what exactly is in the library by returning a table of all of the function names in the library. To figure out all of the values in RbxGui, simply run this code in your command bar in Studio:
table.foreach(LoadRobloxLibrary("RbxGui"):GetApi(), function(index, value) print(index, "=>", value) end)
This piece of code iterates through the table returned by GetApi and prints out the contents of the table.
Also, if it is an official library, there is often a Help function associated with it. To use it, just call the Help function from the library loaded into your code.
So, is that it?
That is all there is to it. Let's recap upon what we've learned today.
What is RbxGui?
RbxGui is an official Roblox-created library consisting of useful functions that are designed to help you make enticing GUIs.
How do I use it?
To use RbxGui, you must load it into your code and then call its members, which are designed to do things that would normally take more time to do.
How do I know what's in the library?
You have to iterate through the table returned by GetApi and print out the values of it. You can also use the Help function in the library with the values of the table.
Concluding mumbo-jumbo
That's all there is to using the RbxGui library created by Roblox. I hope you'll have as much joy using the library as I've had writing this article to teach you to use it.