Having trouble prompting purchase

Hey there, I am trying to use PromptProductPurchase so people can buy my product. However, I have to work my way around using RemoteEvents but when I click the button nothing happens. I have parts of my scripts that may help solve the problem.

Event handler (Script)
local function onPurchasePrompt(player, button)
			local MarketplaceService = game:GetService("MarketplaceService")
			local scrollingframe = game.StarterGui.BuyMoreCharacters.MainFrame.ScrollingFrame
			local tiny = 1297667732
			local small = 1297667556
			local medium = 1297667557
			local large = 1297669211
			local verylarge = 1297669603
			local extremelylarge = 1297670063
			local largest = 1297670613
			local tinybutton = scrollingframe.TinyPurchase
			local smallbutton = scrollingframe.SmallPurchase
			local mediumbutton = scrollingframe.MediumPurchase
			local largebutton = scrollingframe.LargePurchase
			local verylargebutton = scrollingframe.VeryLargePurchase
			local extremelylargebutton = scrollingframe.ExtremelyLargePurchase
			local largestbutton = scrollingframe.LargestPurchase
			
			if button == tinybutton then
				MarketplaceService:PromptProductPurchase(player, tiny)
			elseif button == smallbutton then
				MarketplaceService:PromptProductPurchase(player, small)
			elseif button == mediumbutton then
				MarketplaceService:PromptProductPurchase(player, medium)
			elseif button == largebutton then
				MarketplaceService:PromptProductPurchase(player, large)
			elseif button == verylargebutton then
				MarketplaceService:PromptProductPurchase(player, verylarge)
			elseif button == extremelylargebutton then
				MarketplaceService:PromptProductPurchase(player, extremelylarge)
			elseif button == largestbutton then
				MarketplaceService:PromptProductPurchase(player, largest)
			end
		end
		
		game:GetService("ReplicatedStorage").PurchaseCharacters.OnServerEvent:Connect(onPurchasePrompt)
Click button (LocalScript)
local button = script.Parent
local rep = game:GetService("ReplicatedStorage")

button.MouseButton1Click:Connect(function()
	rep.PurchaseCharacters:FireServer(button)
end)

Keep in mind this is in every button

Just use PromptPurchasePurchase on the client. No need for all this hassle. You have to reference PlayerGui instead of StarterGui, also, some UI objects might not exist on the server. Do it on the client and it will be much easier.

1 Like

It’s rewarding stuff that is making this a hassle. I am not aware of any other way to do this so I put the remote handler inside the script with the leaderstats or else I will get an error

You’re supposed to be rewarding stuff for products using MarketplaceService.ProductReciept. Read this to understand how to do it: Developer Products | Roblox Creator Documentation