I know this sounds dumb, but I have been looking up how to script a gamepass in. I’ve watch video after video. I’ve done it this and that way, but nothing works. Right now I’m trying to do a simple one. A gamepass that gives you a certain gun. So I need feedback.
You would use
MarketplaceService (https://developer.roblox.com/en-us/api-reference/class/MarketplaceService) to check / prompt the purchase of the gamepass.
For example, to prompt the player to buy a gamepass, you would do:
MarketplaceService = game:GetService("MarketplaceService") local Player = [PLAYER] local GamepassID = [ID OF GAMEPASS] MarketplaceService:PromptGamePassPurchase(Player, GamepassID)
In order to check if the player has a gamepass, you would do:
MarketplaceService = game:GetService("MarketplaceService") local Player = [PLAYER] local GamepassID = [ID OF GAMEPASS] local OwnsGamepass = MarketplaceService:UserOwnsGamePassAsync(Player.UserId, GamepassID) if OwnsGamepass then print("They have the gamepass!") end
To create a working gamepass you need to first :
Prompt it from the client using : https://developer.roblox.com/en-us/api-reference/function/MarketplaceService/PromptGamePassPurchase (Just put the player object and Gamepass ID from the URL as parameters respectively)
Use PromptGamePassPurchaseFinished to give the player what he’s just bought : https://developer.roblox.com/en-us/api-reference/event/MarketplaceService/PromptGamePassPurchaseFinished
Then, for returning users you’d need to use UserOwnsGamePassAsync as explained in the post above.
So if i do all of that and fill in the stuff it will work?
Yes it should work. As @INC0GN1TUS said, if they are buying the gamepass in game, you would need to use the
PromptGamePassPurchaseFinished event to detect when the player finished buying the gamepass.
Guys the only thing i can script is a donation button. lol. I should probably hire someone. I suck at scripting.
@Quackers337 has just given you the code for the prompt (PromptGamePassPurchase) and checking whether the user owns the gamepass (UserOwnsGamePassAsync) all you need to add is the PromptGamePassPurchaseFinished and you can find an example of that on the links I provided.
Of course not lol, everyone starts off bad. You get better with experience and practice. By hiring someone else you will not get better, unless you read through their scripts and actively try to understand what is going on. Then again, you can never be sure of the quality of their scripts. It is best to learn how to script yourself because then you are self-sufficient in this regard and don’t need to depend on others
Or if you don’t have time you can just hire a scripter.
I know nothing about scripting. I’m just a guy that has a dream of scripting but cant
ill try it and see if it works. Thanks for the feedback.