Create robux based purchase of button in tycoon

I know of processreceipt, but I am unsure how that could work here. Ideally, after I prompt them to purchase the item, it’d check if they actually purchase the product, and if they do I can then do self.Tycoon:PublishTopic("Button", id), and if I did processreceipt from another script it wouldn’t work cause I can’t do that

function Button:OnTouched(hitPart)
	local Character = hitPart:FindFirstAncestorWhichIsA("Model")
	if not Character then return end
	
	local Player = Players:GetPlayerFromCharacter(Character)
	if not Player or Player ~= self.Tycoon.Owner then return end
	
	local Id = self.Instance:GetAttribute("Id")
	local Cost = self.Instance:GetAttribute("Cost")
	local Cash = PlayerService:GetCash(Player)
	
	if self.Instance:GetAttribute("Robux") then -- Robux purchase
		MarketplaceService:PromptProductPurchase(Player, self.Instance:GetAttribute("ProductId"))
		--// CHECK IF PURCHASED
		return
	else
		if Cash < Cost then -- Not enough cash
			MarketplaceService:PromptProductPurchase(Player, 1188967628)
			--// CHECK IF PURCHASED
			return
		end
	end
	
	PlayerService:SetCash(Player, Cash - Cost)
	
	self.Tycoon:PublishTopic("Button", Id)
end

You should decouple your purchase handling from the button logic. In a separate script, you will handle the MarketplaceService.ProcessReceipt callback, and you can add various handlers for different products there. Check out the code example at the bottom of the documentation MarketplaceService.ProcessReceipt, specifically at lines 56-60.