How to use image buttons

hey developers , i been searching how to make image buttons but i didn’t find any , does anyone know how to script image buttons

4 Likes

Image buttons are used to display images, such as rounded guis.
43%20AM
You can use them for a lot more things.
Image buttons can be scripted the same way like normal text buttons, nothing changes.

1 Like
ImageBtn.MouseButton1Down:Connect(function(
   print("Hi")
end)

Perhaps you were asking that?

4 Likes

This question is a little bit vague. Simply asking for “how to script something” could mean a lot of things. A little bit more information on what you want to do would be appreciated.

Creating Images

You can create an ImageButton using instance.new like most other objects.

local button = Instance.new(“ImageButton”)

From there, you can set properties like the image.

Setting the Image

You can set the image of the ImageButton using the Image property, like so:

button.Image = “rbxassetid://0000000”

The Image property contains the ID of the decal the display.

There are also properties to set the image when it is hovered, pressed and some others.

Events

As @RuizuKun_Dev showed above, you can simply connect events to the ImageButton like you would for most other things. ImageButtons share nearly all of the events that normal buttons do. As a side note, if you’re interested, this happens because an ImageButton is descended from a normal button. It inherits these properties.

Wiki Resources

If your question still hasn’t been answered, use the following link to find out more:

https://developer.roblox.com/api-reference/class/ImageButton

The wiki is the official point of reference for any property or class (or anything) you need to understand. If I’ve not answered your question, try there.

3 Likes

I would say to start off by looking at Roblox tutorials first, they’re available on the Roblox Wiki.

If one of the replies answered the question of your original post, please mark the correct solution, so the community can easily find the solution. Thanks, happy scripting!

1 Like

Scripting an image button is no different to scripting a normal text button on ROBLOX, the only difference is that you can set it as in image instead of text.

A basic example of how to use an image button for something (in this case opening a Gui would be):

--Local script inside image button.
--Function that runs when MouseButton1 is clicked.
script.Parent.MouseButton1Click:Connect(function()
--Define the local player (its in a local script so its easy)
	local player = game.Players.LocalPlayer
--Open that specific GUI. Note this is done via enabled and not visible.
	player.PlayerGui.NameOfGui.Enabled = true
end)
2 Likes

Have you found the solution yet? Are there any other related questions you’d like to ask?

If you don’t know how to mark a solution, it’s just by clicking that checkmark to the side of heart button.

2 Likes

how do i make an image button fire an event when it is pressed

Its the same as a normal button! it uses mousebutton1click

script.Parent.MouseButton1Click:Connect(function()
	-- your code
end)