MouseButton1Down not working on mobile for button inside ScrollingFrame and SurfaceGui

I’m having a very specific issues where I’m not able to trigger “MouseButton1Down” on mobile (works fine on PC) for an ImageButton that is inside a ScrollingFrame and inside a SurfaceGui.

The SurfaceGui is inside the PlayerGui and parented to a part in the Workspace, the button works when parented to a regular “Frame” inside the SurfaceGui but not when inside the “ScrollingFrame” I need the scrolling frame because I’m using it for a list where players can vote by clicking on the like/dislike inside each frame.

I know the issue is directly related to having a button inside the ScrollingFrame but I’m not sure why. I would appreciate the insight of anyone that has had a similar issue.

2 Likes

Hey! I have had a similiar issue, not sure if it helps though. However, you may try this:

Instead of using the MouseButton1Down function, try using Activated instead, seen that it is a SurfaceGui.

If that doesn’t help, you could try putting the SurfaceGui into StarterGui service and setting the Adornee property to the part you want the SurfaceGui to appear on.

Sorry if it doesn’t help!

1 Like

None of this solutions worked sadly.

ok guys so instead of rewriting whole big bang theory we could just probably do this:

first off when you have a button inside a scrolling frame, it might or might not be consumed by the scrolling action, especially if the touch starts on the button and then moves slightly. this could prevent the MouseButton1Down from being triggered. :flushed:

now how do we solve this problem? well, one solution I can think of is to use InputBegan event instead of MouseButton1Down. This event is triggered as soon as the user touches the screen, which makes it more suitable for mobile interfaces.

just add this to your script don’t remove anything that’s currently there. insert your code that is after the MouseButton1Down where – Your Code here is

ImageButton.InputBegan:Connect(function(input)
    if input.UserInputType == Enum.UserInputType.Touch then
        -- Your code here (replace with the code y'know)
    end
end)

also remember to replace ImageButton with the actual reference to your ImageButton so you don’t forget that.

hope this helps!!

4 Likes

You’re a hero! Thank you so much, it worked like a charm!

1 Like

no problem! glad I could help! :smiley:

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