Hello. I'm pretty new to scripting. Though, I'm willing to start somewhere and mostly for my game. I want to make a button where my gamepass can be bought using a button in the game and give the player a sword?
You would need to use PromtProductPurchase
Wiki Page; http://wiki.roblox.com/index.php?title=API:Class/MarketplaceService/PromptProductPurchase
Example;
local productId = 123456 --Id of the product you want to sell game.Players.PlayerAdded:connect(function(player) Game:GetService("MarketplaceService"):PromptProductPurchase(player, productId) --Will offer the player to buy something when they join a game end)
Note: You NEED to get the player, so if you want to do a GUI button, it would be this code:
--Goes in the button local productId = 123456 script.Parent.MouseButton1Click:connect(function() local player = script.Parent.Parent.Parent.Parent.Parent--Get the location of the player, so you can adapt it to your settings. game:GetService("MarketplaceService"):PromptProductPurchase(player, productId) end)
Hope I helped!