Thankyou GUI event

Im making it so after you buy the gamepass, a GUI pops up!

local MarketplaceService = game:GetService("MarketplaceService")local DataStor - Pastebin.com code is here. It prints on the FIRST hi, but not the second.

Try adding this at the start of the processReceipt function:

print (receiptInfo)
for i, v in pairs(receiptInfo) do
	print ("I: " .. i)
	print ("V type: " .. typeof(v))
	print ("V: " .. v)
end

This will show you what data is being returned by the callback(?)
I recognise the code as from the Developer Education stuff. I had a few problems getting it to work properly. Below is the code I ended up using which has only minor differences to that from Roblox, but I couldn’t get it to work as shown on the site without changes
‘’’
local function processReceipt(receiptInfo)
–print (receiptInfo)
–for i, v in pairs(receiptInfo) do
– print ("I: " … i)
– print ("V type: " … typeof(v))
– print ("V: " … v)
–end
– Determine if the product was already granted by checking the data store
local playerProductKey = receiptInfo.PlayerId … “_” … receiptInfo.PurchaseId
print("DB Save Key: ", playerProductKey)
local purchased = false
local success, errorMessage = pcall(function()
purchased = receiptHistoryStore:GetAsync(playerProductKey)
end)
– print(success, purchased) – true nil for No Duplicate Receipt
– If purchase was recorded, the product was already granted
if success and purchased then
return Enum.ProductPurchaseDecision.PurchaseGranted
elseif not success then
error(“Data store error:” … errorMessage)
end

-- 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)
print("Player Update: ", success, result)
if not success then
	warn("Error occurred while processing a product purchase")
	print("ProductId:", receiptInfo.ProductId)
	print("Player:", player)
	return Enum.ProductPurchaseDecision.NotProcessedYet
end

-- Record transaction in Receipt datastore so it isn't granted again
local success, errorMessage = pcall(function()
	receiptHistoryStore:SetAsync(playerProductKey, true)	-- Save the Receipt to DS
end)
 print("Receipt Save: ", success, errorMessage)
if not success then
	error("Cannot save purchase Receipt data: " .. errorMessage)
end

– Record Donation to DS for records
print("Player & Amount: ", tostring(receiptInfo.PlayerId), receiptInfo.CurrencySpent)
local success, errorMessage = pcall(function()
donationHistoryStore:SetAsync(tostring(receiptInfo.PlayerId), receiptInfo.CurrencySpent)
end)
print("Donation Save; ", success, errorMessage)
if not success then
error("Cannot save Donation data: " … errorMessage)
end
print (“Thank player”)
thankPlayer(player.Name)

– IMPORTANT: Tell Roblox that the game successfully handled the purchase
return Enum.ProductPurchaseDecision.PurchaseGranted
end
‘’’
Obviously datastore changes, etc, but you should be able to clearly see where it differs from the original. The problems were detailed here: