i see your script.
if youre using a gamepass:
local productId = 1138688305
game.Players.PlayerAdded:Connect(function(player)
Game:GetService("MarketplaceService"):PromptProductPurchase(player, productId)
end)
if its a devproduct:
local MarketplaceService = game:GetService("MarketplaceService")
local Players = game:GetService("Players")
local productID = 1138688305
local function promptPurchase()
local player = Players.LocalPlayer
MarketplaceService:PromptProductPurchase(player, productID)
end
after that you need to insert another script in serverscriptservice if youre using a devproduct to get the robux... you forgot that.
but you have to add a benifit for that donation. how about 1 gold(lol)?
local MarketplaceService = game:GetService("MarketplaceService")
local DataStoreService = game:GetService("DataStoreService")
local Players = game:GetService("Players")
local purchaseHistoryStore = DataStoreService:GetDataStore("PurchaseHistory")
local productFunctions = {}
productFunctions[1138688305] = function(receipt, player)
local stats = player:FindFirstChild("leaderstats")
local gold = stats and stats:FindFirstChild("Gold")
if gold then
gold.Value = gold.Value + 1
return true
end
end
local function processReceipt(receiptInfo)
local playerProductKey = receiptInfo.PlayerId .. "_" .. receiptInfo.PurchaseId
local purchased = false
local success, errorMessage = pcall(function()
purchased = purchaseHistoryStore:GetAsync(playerProductKey)
end)
if success and purchased then
return Enum.ProductPurchaseDecision.PurchaseGranted
elseif not success then
error("Data store error:" .. errorMessage)
end
local player = Players:GetPlayerByUserId(receiptInfo.PlayerId)
if not player then
return Enum.ProductPurchaseDecision.NotProcessedYet
end
local handler = productFunctions[receiptInfo.ProductId]
local success, result = pcall(handler, receiptInfo, player)
if not success or not result then
warn("Error occurred while processing a product purchase")
print("\nProductId:", receiptInfo.ProductId)
print("\nPlayer:", player)
return Enum.ProductPurchaseDecision.NotProcessedYet
end
local success, errorMessage = pcall(function()
purchaseHistoryStore:SetAsync(playerProductKey, true)
end)
if not success then
error("Cannot save purchase data: " .. errorMessage)
end
return Enum.ProductPurchaseDecision.PurchaseGranted
end
MarketplaceService.ProcessReceipt = processReceipt
note: roblox does not handle these devproduct purchases, so you must NOT alter the core script. you do not need the above script for a gamepass.
2 comments
Why are you doing this on the client? This is the most ineffective way to get any user a gamepass, or an item for that matter. Prompt the purchase on the server.
erm mate, you did not get the robux you mean? Read this article, you need to wait 3-7 days: https://devforum.roblox.com/t/incoming-adjustment-to-pending-sales-waiting-period/832724