Libraries and Samples/ImageInputLibrary

The Roblox Input Image Library is designed to give developers quick and easy access to high quality and standard images for various inputs on a gamepad.

ImageLibraryExample.png

Requiring the library[edit]

The library is hosted on the Roblox account as a ModuleScript. It can be included by requiring its assetId: 408470686

To require the module in a local script

local ModuleAsset = game:GetService('InsertService'):LoadAsset(408470686)
local InputImageLibrary = require(ModuleAsset.MainModule)


To require the module in a server script

local InputImageLibrary = require(408470686)

Functions[edit]

   ImageLabel GetImageLabel(imageName, style)

This function takes two arguments. The first is the name of the image, which can be either a string or a KeyCode. Note that only gamepad keycodes are valid. There are also several images that are not traditional inputs that require a string to access via this function (see #Image List). The second argument is the style of the image; The current styles are Light and Dark.

This function returns an ImageLabel if a valid imageName and style are provided, otherwise it returns nil. The ImageLabel will be sized by default to the raw size of the image.

   ImageButton GetImageButton(imageName, style)

This function operates identically to GetImageLabel, except it returns an ImageButton instead of an ImageLabel.

Image List[edit]

ImageLibraryDarkStyle.png

ImageLibraryLightStyle.png

Number Name KeyCode
1 Controller n/a
2 ButtonA Enum.KeyCode.ButtonA
3 ButtonB Enum.KeyCode.ButtonB
4 ButtonX Enum.KeyCode.ButtonX
5 ButtonY Enum.KeyCode.ButtonY
6 ButtonSelect Enum.KeyCode.ButtonSelect
7 DPad n/a
8 DPadLeft Enum.KeyCode.DPadLeft
9 DPadDown Enum.KeyCode.DPadDown
10 DPadRight Enum.KeyCode.DPadRight
11 DPadUp Enum.KeyCode.DPadUp
12 ButtonL1 Enum.KeyCode.ButtonL1
13 ButtonR1 Enum.KeyCode.ButtonR1
14 ButtonL2 Enum.KeyCode.ButtonL2
15 ButtonR2 Enum.KeyCode.ButtonR2
16 ButtonL3 Enum.KeyCode.ButtonL3
17 ButtonR3 Enum.KeyCode.ButtonR3
18 Thumbstick1 Enum.KeyCode.Thumbstick1
19 Thumbstick2 Enum.KeyCode.Thumbstick2
20 RotateThumbstick1 n/a
21 RotateThumbstick2 n/a

Sample Code[edit]

To generate an ImageButton or ImageLabel simply call the associated function and pass in the name of the controller element as per the names in #Image List:

local ModuleAsset = game:GetService('InsertService'):LoadAsset(408470686)
local InputImageLibrary = require(ModuleAsset.MainModule)
local player = game.Players.LocalPlayer
local playerGui = player:WaitForChild("PlayerGui")
local screenGui = Instance.new("ScreenGui", playerGui)
 
local l3Image = InputImageLibrary:GetImageLabel("ButtonL3", "Dark")
l3Image.Parent = screenGui

In some cases a KeyCode is also accepted as an argument:

local ModuleAsset = game:GetService('InsertService'):LoadAsset(408470686)
local InputImageLibrary = require(ModuleAsset.MainModule)
local player = game.Players.LocalPlayer
local playerGui = player:WaitForChild("PlayerGui")
local screenGui = Instance.new("ScreenGui", playerGui)
 
local dPadDownImage = InputImageLibrary:GetImageLabel(Enum.KeyCode.DPadDown, "Light")
dPadDownImage.Parent = screenGui