Mobile players clicking a surface gui button

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

Use MouseButton1Click instead apparently

1 Like

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):

  1. 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)

what? that is the exact same as what i have shown

This is what happens when someone doesn’t read the post’s description…

2 Likes

it does work for ui but if youre talking about surface guis then im sorry

Is your SurfaceGui in the workspace?
Only SurfaceGuis in StarterGui can register button inputs as far as I know…

yes its in workspace but the solution works fine, im not sure why

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