Iv'e been looking at a few scripts and each one I try says GamePassService and I have heard that it GamePassService does not work anymore so what I am I able to do?
COMMUNITY QUESTION
How am I able to make a gamepass give in-game cash?
1 answer
*Script Location: ServerScriptService
Script Information: This handles purchases (note, you can only have one script handling purchases per game)*
local MarketplaceService = game:GetService("MarketplaceService")
local gamepassid = 0
function getPlayerFromId(id)
for i,v in pairs(game.Players:GetChildren()) do
if v.userId == id then
return v
end
end
return nil
end
MarketplaceService.ProcessReceipt = function(receiptInfo)
local productId = receiptInfo.ProductId
local playerId = receiptInfo.PlayerId
local player = getPlayerFromId(playerId)
if productId == gamepassid then
player.leaderstats.cash.Value = player.leaderstats.cash.Value + 300
end
return Enum.ProductPurchaseDecision.PurchaseGranted
end
*Script Location: StarterGui
Script Information: This handles the purchasing when you click a button*
local plr = game.Players.LocalPlayer
local button = script.Parent
local gamepassid = 0
button.MouseButton1Down:connect(function()
game:GetService("MarketplaceService"):PromptProductPurchase(plr, gamepassid)
end)
Hope that helped :)
This discussion is preserved as it was. New answers, comments, and votes are closed.
