Mobile users unable to interact with textbuttons?

  1. What do you want to achieve? Close/Open frame when textbutton is tapped

  2. What is the issue? Mobile users cant interact with the textbuttons but pc users

  3. What solutions have you tried so far? I tried removing uicorners and using touchtap function but it still wouldnt work

Forgot to mention that textbutton with closebutton script is the one not working (alongside with all the textbuttons)

script.Parent.MouseButton1Click:Connect(function()
	print("jjidfd")
end)

Here is the whole gui location with its frames.

image

and its properties

2 Likes

Take a look at TextButton.InputBegan and/or UserInputService

GuiObject.MouseButton1Click() is a pretty old event that only works with mouse click inputs (afaik).

So I always use this code for my interactive UI elements, whether they are ImageButtons, TextButtons, ImageLabels, TextLabels, etc. Works with all. And works with all device inputs; Console, PC, Mobile!

YourButton.InputBegan:Connect(function(i)
        if i.UserInputType ~= Enum.UserInputType.MouseButton1 and i.UserInputType ~= Enum.UserInputType.Touch and i.KeyCode ~= Enum.KeyCode.ButtonA then return end
-- do stuffs
    end)

OR

YourButton.InputBegan:Connect(function(i)
        if i.UserInputType == Enum.UserInputType.MouseButton1 or i.UserInputType == Enum.UserInputType.Touch or i.KeyCode == Enum.KeyCode.ButtonA then
           -- Do stuff
        end
    end)

Keep up the good work, hope this helps! :grin:

1 Like

Try:
script.Parent.Activated
Even though MouseButton1Click always works for me.

Your solution works most of the time but some time it barely works at all it’s like the script disabled itself.

At where it says “script.Parent.MouseButton1Click”
Try “script.Parent.Activated” instead

Is that the full script or are you leaving bits out?

Yes that is the full script.

This text will be blurred

Nope still doesnt work the button was a highlighted for a bit then stopped working (Playtesting on mobile device)

Ok, MouseButton1Click should work as I recently made a dungeon lobby thing with all the UI to Join, Create, Leave, and Start a game. I play tested on mobile and laptop and both ways work. Try playtesting on a REAL/Physical mobile device, and try this script:

script.Parent.MouseButton1Click:Connect(function()
    local r = math.random(0, 255)
    local g = math.random(0, 255)
    local b = math.random(0, 255)
    script.Parent.BackgroundColor3 = Color3.fromRGB(r,g,b)
end) 

If the color changes, that means it works

I am playtesting on a physical device that’s why i opened this topic, the textbutton does not work for me (I am using Iphone xr) and alongside with some other mobile users too.

Can you publish the game and link it here, I would like to test it myself

I’ll give you the rbxl with the screengui and proximity prompt that opens it in messages if you wanna.

No, no rblx, im only in mobile rn

Did you try my script, cause you can’t see the output when testing on mobile (can you?)

I did try it i changed the output to making the frame (textbutton) invisible but it wouldnt work. also i’ll be sending you a game link with the gui right now.

1 Like

Here it i, i will be there waiting for you. Mobile Gui testing - Roblox

Well, I might have a real hacky solution:

local UIS = game:GetService("UserInputService")
local Players = game:GetService("Players")
local SG = game:GetService("StarterGui")
local Player = Players.LocalPlayer

local Mouse = Player:GetMouse()

local function OnButtonClick(Button)
    print("It was clicked")
    Button.Visible = false
end

UIS.InputBegan:Connect(function(input)
    if input.UserInputType == Enum.UserInputType.MouseButton1 then
        local GUIObjs = SG:GetGuiObjectsAtPosition(Mouse.X, Mouse.Y)
        for _, obj in pairs(GUIObjs) do
            if not obj:IsA("Button") then continue end
            OnButtonClick(obj)
        end
    end
end)

I have no idea if this works

Wouldn’t MouseClick also work? Or is that essentially the same thing as MouseButton1Click?

Found the solution by myself it apparently was

script.Parent.MouseButton1Down:Connect(function()
	script.Parent.Parent.Enabled = false
	end)

Apparently MouseButton1Up only works if player is holding the exit button.

https://developer.roblox.com/en-us/api-reference/event/GuiButton/Activated

1 Like