Hey! I have the following code (shortened, as there are many buttons and prompts of purchase in this single script - along with other stuff):
local plr = game:GetService("Players").LocalPlayer
local mps = game:GetService("MarketplaceService")
local id = (valid_id)
local button = (button_path)
button.MouseButton1Click:Connect(function() mps:PromptGamePassPurchase(plr, id); print("Buy") end)
When I click the button, it does not always prompt the gamepass purchase, however it always prints in the console, suggesting that the code is running and the issue is with the prompt. I have to click the button twice to get the prompt to appear on the screen, despite “Buy” printing on the all times.
Any ideas how to fix this, as it’s not great for UX (User Experience) to have to click a button twice to prompt a purchase.
This occurs when I first load into the game - for the majority of prompts it requires multiple clicks - so I shouldn’t have been in a cooldown already?
Thanks for confirming my code is alright, I guess I’ll walk away for a bit now, maybe I’m overlooking something obvious and coming back with a fresh mind later might see it.
Hey all! Sorry for the reply ~24 hours later, I’ll answer some questions given:
It’s in a “clean” game, so nothing else is here apart from these scripts! Shouldn’t be interference.
They are text buttons, but with other GUI elements embedded inside them (for other effects that I do). Buttons are absolutely fine and responsive, as I say they log when I click them, and they have the hover effect as expected.
Yep! One of the first things I checked!
I’m not sure what it is, but I’ve play tested multiple times today and it seems to be resolved, whatever it is - with no further updates. Maybe I was in a weird cooldown loop, like @Xacima suggested especially since it was occasionally working, but I cannot be sure.