개발자 제품

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

개발자 제품 만들기

  • 정보 업데이트
  • 저장
  • 개발자 제품으로 다시 이동하여 업데이트된 제품 ID를 확인하세요.
  • ID를 클립보드에 복사
Image 1
Image 2
Roblox Studio

구매 시작

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
)

Roblox 구매 응답

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

… processReceipt Method


MarketplaceService.ProcessReceipt = processReceipt

응답 처리

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

성공적인 구매 논리

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

이 튜토리얼이 도움이 되셨다면, 저의 작업을 지원하기 위해 커피 한 잔을 사주시면 감사하겠습니다.

지원해 주셔서 정말 감사합니다!

커피 한 잔 사주기