Alternative for MouseButton1Click at ImageButton

Hello there!

I am currently developing GUI at Roblox Studio and prepared everything in regard to the frames. Now, to make the frames appear and disappear once clicking a button, I created a script underneath an ImageButton and begin to structure it simply:

local BadgeFrame = game.Players.LocalPlayer.PlayerGui.BadgeGui.BadgeFrame.PageFrame

script.Parent.MouseButton1Click:Connect(function()
    BadgeFrame.Visible = true
end)

Testing the experience and the button at Roblox Studio, in the Output, it turns out that MouseButton1Click is not a valid member for the ImageButton, leading to making an error. Oddly, I decided to take a look into other options for Mouse, and those that are “close” were MouseEnter and MouseLeave, but sincerely they appear to not help and make sure to have the visibility all in all until another event is fired separately… I tried checking out other experiences of mine and analyzed that MouseButton1Click appears to only work for TextButton.

Therefore, I would like to know if there is any alternative that can solve my little issue. If anyone can help me with this, I would really appreciate it!

Thank you! :smile:

An Alternative for MouseButton1Click is Activated which in theory should activate for all devices

local BadgeFrame = game.Players.LocalPlayer.PlayerGui.BadgeGui.BadgeFrame.PageFrame

script.Parent.Activated:Connect(function()
    BadgeFrame.Visible = true
end)

Tried this right now, yet appears as a non-valid member

image

Can you show your Explorer tab?

Text

Bruh, Looking at the Output i says ImageLabel LOL, I think you were using the wrong Frame

1 Like

Putting this message as solved because silly of me I did not notice that I created the button as in an ImageLabel… Transferred the LocalScript and other properties into an official ImageButton now and MouseButton1Click and Activated are working normally… I apologize for the confusion, @DasKairo

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.