Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How can I make a gui imagebox show when this is toggled?

I have a gui where it can toggle a menu, but I can't figure out how to make it show if it is toggled. This is the code for the parent:

local button = script.Parent
local toggled = false
 
local function onButtonActivated()
	if toggled == false then
		button.Image = "rbxgameasset://Images/Dropdown-active"
		toggled = true
	else		
		button.Image = "rbxgameasset://Images/Dropdown-null"
		toggled = false
	end
end
 
button.Activated:Connect(onButtonActivated)

4 comments

0

What is wrong here? this should work

0

I am asking how to make the child appear once toggled

0

As long as it's in a local script, the images work, and you have the button correctly identified in your variable, it should work. The only thing I can recommend is using print functions everywhere to try to identify the problem.

0

ok thanks

1 answer

✓ Accepted answer

I have an idea. Create two "ImageLabel" Gui's in the same spot, one being the toggled image and one the non-toggled image. Then create a third Gui, this one a "ImageButton" Gui, and make it the same size and position as the two Image Label Guis. The Image Button should have a higher zindex than the Image Labels. Also, make the Image Button totally transparent. Then change your function so it makes the "ImageTransparency" of the desired toggled state Gui 0, and the other 1, making it appear as if the image has been changed.

local button = script.Parent
local toggled = false
local ToggledImage = -- Gui for the toggled image
local NonToggledImage = -- Gui for the toggled image 
 
local function onButtonActivated()
    if toggled == false then
        ToggledImage.ImageTransparency = 0
		NonToggledImage.ImageTransparency = 1
        toggled = true
    else       
        NonToggledImage.ImageTransparency = 0
		ToggledImage.ImageTransparency = 1
        toggled = false
    end
end
 
button.Activated:Connect(onButtonActivated)

This discussion is preserved as it was. New answers, comments, and votes are closed.