I have a ImageButton under a SurfaceGui which is parented to StarterGui
. When clicking the button on a PC, the Activated
event fires just as it should.
When doing this on mobile, though, the Activated
event doesn’t fire, only rarely (mostly when spam-tapping or right after moving my character - both rare occasions).
Hierarchy:
SurfaceGui screenshot:
LocalScript:
wait(3)
local MarketplaceService = game:GetService("MarketplaceService")
local Players = game:GetService("Players")
local LocalPlayer = Players.LocalPlayer
for _, Descendant in ipairs(script.Parent:GetDescendants()) do
if Descendant:IsA("ImageButton") then
if tonumber(Descendant.Name) then
Descendant.Activated:Connect(function()
print("Activated")
MarketplaceService:PromptGamePassPurchase(LocalPlayer, tonumber(Descendant.Name))
end)
end
end
end
Each descendant has Active = true
if possible and the SurfaceGui has an Adornee set, which is not covered by another invisible part.
I’m trying to prompt a gamepass purchase when one of the buttons gets clicked, but the clicking event just doesn’t get fired on mobile. What am I doing wrong?