In the Articles/Intro to GUIs guide, you learned the basics of GUIs, how to create a screen GUI canvas for all players that enter your game, and how to position and resize a TextLabel GUI object on the screen. If you did not read through the Articles/Intro to GUIs guide, please do so first! Show Let’s expand on those concepts and explore how to insert images into the screen GUI space. This is a great way to display icons, logos, background images, and other cool designs on the screen! Adding Images to a Screen GUIAdding an image to a screen GUI is very similar to adding a text label.
This will add an empty image label to the top-left corner of the game view. Upload an ImageThis placeholder is a good start, but obviously we need a real image to put on the screen. Let’s upload an image now. The game must be published to Roblox before you can upload images. If you need help with publishing, please click here.
If you don't see a popup window, your game might not be published. Remember that a game must be published before you can upload images.
If you want to place images over a colorful background on a menu screen or similar, you should make the pixels around the visible parts transparent in your image editing program. This will let the background or other game objects behind show through.
The image is now uploaded and applied to the ImageLabel object. However, there are some properties which we can change to make it look even better!
Layering Images in a Screen GUIGreat! Now you understand how to upload images to Roblox and put them on the screen. When you start adding more than one image, though, you’ll probably need to start thinking about layering. Think about layering objects on the screen GUI space just like putting stickers on a piece of paper. If you stick one sticker on top of another sticker, it will hide that sticker behind it. Sometimes, however, you’ll want to arrange stickers in a different way, perhaps moving those behind to the very front. Create a Second Image LabelLet’s place another image on the screen to demonstrate how layering works.
Note that this image label will have the same name ("ImageLabel") as the first one you created, so make sure you select the correct one by looking for the blue selection outline around the label in the 3D game view.
When the image is finished uploading, you should see the following result: Change the Label PropertiesThe initial properties don’t look good for this image, so let’s fix them.
That should correct everything and the image label should now look like this: Change the Layering OrderAs you can see, the new image label was placed behind the first one. If you don’t like how this looks, you can move the object to the front by changing its Z-index.
Since the ZIndex of the first label (icon) is 1, our setting of 2 for the blue shape pushes it in front. The lowest possible Zindex is 1 but you can set the number as high as you want. We recommended using increments of 10 for each layer, for example 10 for the first object, 20 for the second object, 30 for the third object, and so on. Why? Because you might need to make changes to your layout later and add new objects between existing ones. This way, you can set the Z-index of a new object to a value between the Z-index of either neighbor rather than re-sort every object in the layout. Now you know how to create image labels in your game, upload your own images to Roblox, position labels on the screen GUI canvas, and layer them with Z-indexing. |