Scripting Lesson 004: Simple Guis

Hello everybody, Domswolf here. I am here with a new scripting lesson on Guis

Now you may think, what to guis have to do with scripting? Well like I did with lighting and building, guis (Graphical User Interfaces) are more associated with scripting which is why it is in this area. Now there are different kinds of guis: ScreenGuis, SurfaceGuis, and BillboardGuis. Because Guis are so complex and take a lot of practice and knowledge, the Gui lessons will be spread out throughout the scripting curriculum. Today we will just be talking about ScreenGuis and how to make basic Gui based scripts.

ScreenGuis are obviously, Guis that appear on your screen. You have probably seen these on many of your favorite roblox games. The checks you get on "Work at a Pizza Place" by Dued1 is an example of a ScreenGui.

Now these guis can be used for things like the check, but also as menus. So how do we insert one of these into our games? Well first you collapse your Workspace (like you did to get to Lighting) and you go down to where it says StarterGui and insert a ScreenGui with your Advanced Objects list. Inside of the ScreenGui you want to insert a TextLabel, a TextButton, or a TextBox. (Once again, TextBoxes are topics for the next Gui lesson). A TextLabel is just simply a box with text on it (can obviously be used as a label as seen below). A TextButton is a Box where if you click, it activates the script inside of it, similar to the onClicked function from before.

So for an example, I have toggled and messed around with the properties of the gui label (and button labeled Click) so that when the button is pressed, the label changes its text. Here is what it will look like. Once again I have written some helpful tips on what the script is doing:

Now with some scripts having to do with guis you would have to identify a character using GetPlayerFromCharacter (which will be explained in the next lesson). That occurs in situations where we would press on a brick or something in the workspace to trigger the script, but in this example, the script is in the TextButton as it should, so all you have to do is go back two parents to get to ScreenGui then narrow it down to the text in the label. (Note that I accidentally mis-worded the text of the label. It should say below, not above)

You also need to remember how to make the text. Since the text is...well...text...and has no number value like Transparency or Position does, we would do parenthasis with quotation marks inside to make the text actually work. (Unless you have changed your settings) The text in your script should appear a purplish color so you know if you did it right.

You can also use Guis for other purposes obviously. For examples, look at the Extra Practices I have at the bottom. Thanks for tuning in to this short, but helpful lesson. Next lessons we will discuss how to make a brick rotate and move either on its own or by a trigger, and how to use more guis and how to narrow down to one single player's gui. See you there!

FYI, two lessons from now we will begin our first assessment. If you wish to use scripting instead of building to level up to Dev Trainee, look at the bottom of the lesson list.

Exercise- Make a gui button that resets your character

Challenge- Make a gui button that decreases your health by 5 each time you click it.

-Domswolf