Produtos do Desenvolvedor

Roblox Studio
>
File
>
Game Settings
>
Monetization
>
Developer Products
>
Create
Image 1
Image 2
Roblox Studio

Criar Produtos do Desenvolvedor

  • Atualizar Informação
  • Salvar
  • Vá para Produtos do Desenvolvedor novamente para verificar o ID do produto atualizado
  • Copiar ID para a Área de Transferência
Image 1
Image 2
Roblox Studio

Iniciar Compra

local productId = YOUR_PRODUCT_ID  
local MarketplaceService = game:GetService("MarketplaceService")

game.Workspace:WaitForChild("ATM"):WaitForChild("SurfaceGui"):WaitForChild("Purchase").Activated:Connect(
	function()
		MarketplaceService:PromptProductPurchase(player, YOUR_PRODUCT_ID)
	end
)

Resposta de Compra do Roblox

local productId = YOUR_PRODUCT_ID  
local MarketplaceService = game:GetService("MarketplaceService")

… processReceipt Method


MarketplaceService.ProcessReceipt = processReceipt

Processar Resposta

local function processReceipt(receiptInfo)

	-- Find the player who made the purchase in the server
	local player = Players:GetPlayerByUserId(receiptInfo.PlayerId)
	if not player then
		-- The player probably left the game
		-- If they come back, the callback will be called again
		return Enum.ProductPurchaseDecision.NotProcessedYet
	end

	-- Look up handler function from 'productFunctions' table above
	local handler = productFunctions[receiptInfo.ProductId]

	-- Call the handler function and catch any errors
	local success, result = pcall(handler, receiptInfo, player)
	if not success or not result then
		warn("Error occurred while processing a product purchase")
		print("ProductId:", receiptInfo.ProductId)
		print("Player:", player)
		return Enum.ProductPurchaseDecision.NotProcessedYet
	end

	return Enum.ProductPurchaseDecision.PurchaseGranted
end

Lógica para Compra Bem-Sucedida

local productId = YOUR_PRODUCT_ID  

local productFunctions = {}

productFunctions[YOUR_PRODUCT_ID] = function(receipt, player)

	-- examle of udpates for successful purchase
	local d = players_holder[player.Name]
	d["coin"] = d["coin"] + 200000
	fire_player_event_local(player, d)
	return true
end

Se você achou este tutorial útil e gostaria de apoiar meu trabalho, por favor, considere me comprar um café.

Muito obrigado pelo seu apoio!

Me compre um café