local productId = 322937935
script.Parent.MouseButton1Click:connect(function()
local player = script.Parent.Parent.Parent.Parent.Parent
game:GetService("MarketplaceService"):PromptProductPurchase(player, productId)
end)
This script is meant to have a player buy a gamepass when a GUI TextButton is pressed, but when I press it, it won't work. Can somebody please fix this?

2 comments
What kind of script is this and what is it under in the Explorer?
It's a normal script and it's supposed to be for a GUI button where when you press it, you can buy something.