MouseButton1Up is not vaild member of ImageLabel

I’m new to scripting so i might not know how things work

recently i want to make a Picture Scrolling down when clicked but one problem is how they didn’t tend to work because the error just came

Codes inside:
image

and this is what happen when i loaded into the game

it won’t do anything, but just stay as there

Do i need to replace something with another new Instance?

2 Likes

Its because your using a image label, use a image button instead!

4 Likes

No, however i have one imagebutton as it was linked to the code itself but it wasn’t doing anything

1 Like

can you show me the hierarchy of the GUI?

I can’t screenshot more but i remember what i have placed inside ScreenGui

Inside ScreenGui contains

  • LocalScript (main script that i showed)
  • One ImageButton named “ShopGUI”
  • One ImageLabel (used for ImageAnimation test)

also inside ImageButton contains one script which is just only appearance as tween

1 Like

If the Image Button is named “Shop GUI”, in your code you have that referenced as “ShopGUI”, therefore instead of referencing your background variable (which is a Image Label), you should reference the ShopGUI variable,

ShopGUI.MouseButton1Up:Connect(function()
    -- Code
end)

the error is self explanatory, you are trying to associate mousebutton1up with an image label, when you should be doing it to a button.

you also complained that you did have it on the button and it did nothing, consider swapping to a MouseButton1Click instead and see if it works AND have it associated with a button and not label or etc.

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

i have tried but this time the error is “Udim2”
here’s what it looks like now


image

thats an error with your code but is proof that the mousebutton1click works.

I believe you forgot the comma after the udim2 stuff

UDim2.new(0.208,0,0.132,0),

I’d appreciate if you mark as solution either first post or this one.

1 Like

Use a image button instead. Other errors are not related but the problem is you are using an image label. Use a image button!

Use this code :slight_smile:

local ShopButton = script.Parent.ShopGui
local Background = script.Parent.Background

ShopButton.MouseButton1Click:Connect(function()

  Background:TweenPosition(
    UDim2.fromScale(0.208,0.132),
    "Out",
    "Quint",
    1,
    false
    )
end)

This one seems to work now
thank you for telling me! I’ll try to remember with this one