Hello! I am trying to make a script that when a button is pressed, prompts the purchase of a gamepass. However, it seems that line 12 is erroring and causing the script not to work.
The Code (Just the error part the error is second line):
local VipGamepass = 12424604
VipButton.MouseButton1Down:Connect(function()
local success, message = pcall(function()
hasPass = MarketplaceService.UserOwnsGamePassAsync(player.UserId, VipGamepass)
end)
if hasPass then
print("Player Already Has VIP Gamepass")
else
MarketplaceService:PromptGamePassPurchase(player, VipGamepass)
end
end)
The error:
21:33:53.296 MouseButton1Down is not a valid member of Frame "Players.NotAid_n.PlayerGui.shop.Shop.ScrollingFrame.VIPgamepass" - Client - ShopScripts:12
21:33:53.297 Stack Begin - Studio
21:33:53.297 Script 'Players.NotAid_n.PlayerGui.shop.ShopScripts', Line 12 - Studio - ShopScripts:12
21:33:53.297 Stack End - Studio
Your problem is that the object VIPButton is actually a frame. Frames do not have a MouseButton1Down event. You would have to switch your frame out for a button.
This is your problem. “VIPgamepass” should be a button. Either a “TextButton” or an “ImageButton” depending on how you want it to look. The alternative would be to add a button inside of the Frame and reference to that.
local OpenShop = script.Parent.openclose -- "Click The Button To
-- Close/Open This is the one im having trouble with.
local CloseShop = script.Parent.Shop.close -- "X" To Close
That doesnt work at all. It just changes the way of clicking it still doesnt pop up when clicked. (so i dont think the .MouseButton1Down Part is the problem)
You definitely want click instead of down. Since you know one is open and the other is close, set the Visible explicitly to true and false for open and close instead of using not.
I want it to be able to be multi-purpose. Also, I have heard Down is way better than click for many reasons. That is clearly not addressing the problem. Also, I tried that and it doesnt work.
Might something be covering up the open/close UI? Possibly when you open the shop, the shop UI covers up the open/close button which would block it from being clicked.
If you have something covering up the button, then it is obstructing the button. When you click, the click is not recieved by the button because you are technically clicking whatever is on top of it.
That was my next guess. Looking at your explorer tree. I assume the image and text that are children of openclose are on top of the button. They would block the click. You would want to put a transparent button on top of them with a higher Z order to catch all clicks.
To follow up with this, I noticed you had a “TextLabel” inside of the button, That shouldn’t be necessary, you should set the “TextButton.Text” to whatever text you want.