Hi devs. I have a list of buttons on a surface gui in my game but in every server of my game i join someone tells me that the donate buttons wont work when their on mobile (i havent tested myself). I think the buttons simply dont register clicks on mobile when on a surface gui. Any help is appreciated!
Script (parent is starter gui, local spript, works completely find on desktop/pc):
local MarketplaceService = game:GetService("MarketplaceService")
local donationID = {1797399830,1797400681,1797400679,1797400677}
wait(1)
local parent = game.Workspace:WaitForChild("Leaderboards"):WaitForChild("Donate")
for i,v in pairs(parent:WaitForChild("Surface"):WaitForChild("SurfaceGui"):WaitForChild("ScrollingFrame"):GetChildren()) do
if v:IsA("TextButton") then
v.MouseButton1Down:Connect(function()
MarketplaceService:PromptProductPurchase(game.Players.LocalPlayer,donationID[tonumber(v.Name)])
end)
end
end
MouseButton1-anything doesn’t work on mobile, seeing as there is no mouse button to click.
You could use TouchTap or this:
v.InputBegan:Connect(function(inp)
if inp.UserInputType == Enum.UserInputType.MouseButton1 or
inp.UserInputType == Enum.UserInputType.Touch then
-- Code goes here
end
end)
Just make an simple script. Example (idk if it’s working):
Add SG in StarterGui and add TB into it, then add this script (should work):
script.Parent.MouseButton1Click:Connect(function()
game:GetService(“MarketplaceService”):PromptProductPurchase(game.Players.LocalPlayer, YOURID)
end
(I just made this script on phone lol)