Can't Open Gui on Mobile

Fixed
10Charssssssssssssssssss

1 Like

What I’d do, is instead connect both of the events inside 1 function so that way it’ll be able to work a bit better


local text = script.Parent.TextLabel
local Button = script.Parent
Box = script.Parent.Parent.Box
local player = game.Players.LocalPlayer
local userInputService = game:GetService("UserInputService")

local function BoxCheck()
    print("Function fired")
    script.Parent.ClickSound:Play()

    if Box.Visible == false then
	Box.Visible = true
	text.Text = "Close"
    elseif Box.Visible == true then
	Box.Visible = false
	Text.Text = "Dev Shop"
    end
end

script.Parent.MouseButton1Click:Connect(BoxCheck)

if userInputService.TouchEnabled then
    print("On mobile")
    script.Parent.TouchTap:Connect(BoxCheck)
end

Could you try this and see what Outputs?

When I went to the console It printed that I was On Mobile however when I tried opening the gui it still didn’t open

Instead of

script.Parent.MouseButton1Click:Connect(function()

use:

script.Parent.Activated:Connect(function()

This should fix it as mousebutton1click sometimes doesn’t detect on mobile
Using this, you don’t even need that User Input service bit, and activated should work immediately for all devices.

1 Like

Ok just to be clear your saying I should change it to this

local text = script.Parent.TextLabel
local Button = script.Parent
Box = script.Parent.Parent.Box
local player = game.Players.LocalPlayer

script.Parent.Activated:Connect(function()

script.Parent.ClickSound:Play()
if Box.Visible == false then
	Box.Visible = true
	text.Text = "Close"
elseif Box.Visible == true then
	Box.Visible = false
	text.Text = "Dev Shop"

end

end)

Yeah, it should work. test it out, and let me know the outcome.

Fixed!
10charsssssssssssssssss

1 Like