You need to have a local script that checks for when the button is clicked. Then you :InvokeServer() with the BindableFunction on the local script, which will then prompt the player to purchase. I’m not sure why you are using Roblox’s SendNotification, but I recommend you use UI instead of Roblox. If you do want to use SendNotification, you need a way to activate it.
I just want a notification to appear asking if they want to buy. I don’t want the gamepass prompt to just appear in the middle of their screen unless they click buy
Then you want to do a while loop for time to ask the user
while wait(60) do
--SendNotification
end
Then you just check for when they press Buy, and then do your BuyGamepass function
I’m not sure how Roblox’s SendNotification works, so you should look it up
The Callback takes a BindableFunction as a parameter. In your code here, you are passing the return value of the function (in this case, nil). You have to create a BindableFunction (including setting the OnInvoke function) and pass the entire object as the callback parameter.
Unfortunately, the only parameter passed is the text of the button that is pressed. You’ll need to know the gamepass ID ahead of time (ie. setting it as a global variable or some other way to keep track of it).
local bindf = Instance.new("BindableFunction")
bindf.OnInvoke = function(buttonText)
...
end
-- In your SendNotification table
{
...
Callback = bindf
...
}
Keep in mind that the OnInvoke function will also call for the Cancel button, which means you need to make sure you’re properly checking which button is pressed.