Developer Product Help!

Goal

I am trying to make a ticket system. When you click a button it prompts the product purchase UI and if they purchase it, it will give you a ticket.

Problem

When the player purchases the gamepass it doesn’t give it. I tested it and it does prompt the purchase just after the closure of it, nothing happens. I am not getting errors or anything.

Scripts

(please ignore my messy coding :laughing:)

Local Script

local regular = script.Parent.Regular
local vip = script.Parent.VIP
local closed = script.Parent.Close
local boosted = script.Parent.Boosted
local plr = game.Players.LocalPlayer
local detector = workspace.TicketGuy2.ClickDetector 
local mps = game:GetService("MarketplaceService")
local productID = 989153195
local player = game.Players.LocalPlayer
local Players = game:GetService("Players")


boosted.MouseButton1Click:Connect(function()
	mps:PromptProductPurchase(player, productID)
	local function processReceipt(receiptInfo)
		
		local person = Players:GetPlayerByUserId(receiptInfo.PlayerId)
		if not person then
			return Enum.ProductPurchaseDecision.NotProcessedYet
		end
		if receiptInfo.ProductId == productID then
			if person then
				print("Purchased")
				game.ReplicatedStorage.GiveBoosted:FireServer()
				print("Remote Event Fired")
			end
		end
		return Enum.ProductPurchaseDecision.PurchaseGranted
	end
end)

regular.MouseButton1Click:Connect(function()
	if plr.leaderstats.SneakyPoints.Value > 4 then
		plr.leaderstats.SneakyPoints.Value = plr.leaderstats.SneakyPoints.Value - 5
		print("Points Deducted")
		game.ReplicatedStorage.GiveRegular:FireServer()
		print("Remote Event Fired")
	end
end)

vip.MouseButton1Click:Connect(function()
	
end)

closed.MouseButton1Click:Connect(function()
	script.Parent.Visible = false
end)

detector.MouseClick:Connect(function()
	script.Parent.Visible = true
end)

Server Script

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local GiveRegular = ReplicatedStorage:WaitForChild("GiveRegular")
local GiveBoosted = ReplicatedStorage:WaitForChild("GiveBoosted")

GiveRegular.OnServerEvent:Connect(function(player)
	print("Client Sent Message")
	local newTicket = ReplicatedStorage.Tickets.Regular:Clone()
	newTicket.Parent = game.Workspace:FindFirstChild(player.Name)
end)

GiveBoosted.OnServerEvent:Connect(function(player)
	print("Client Sent Message")
	local newTicket = ReplicatedStorage.Tickets.Boosted:Clone()
	newTicket.Parent = game.Workspace:FindFirstChild(player.Name)
end)

If you have any questions about the locations of the scripts or anything I am happy to answer!

Where in the code are you giving the player a ticket?

1 Like

Inside the Server Script.

(30 char)

Gamepasses and Dev Products should be handled on the server.

1 Like

Yeah why are you handling it on the client?

1 Like

Ok should I use a Remote Event to prompt it?

Yes that’s pretty much ideal
30 chars

1 Like

You have to since it’s Client to Server.

1 Like

Also, is this a Developer Product or Gamepass? Since both have diffrent methods to check if a player bought them.

1 Like

A developer product. I made the changes and it still won’t work.

Server Script -

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local GiveRegular = ReplicatedStorage:WaitForChild("GiveRegular")
local DevProductPurchase = ReplicatedStorage:WaitForChild("DevProductPurchase")
local mps = game:GetService("MarketplaceService")
local productID = 989153195
local player = game.Players.LocalPlayer
local Players = game:GetService("Players")

GiveRegular.OnServerEvent:Connect(function(player)
	print("Client Sent Message")
	local newTicket = ReplicatedStorage.Tickets.Regular:Clone()
	newTicket.Parent = game.Workspace:FindFirstChild(player.Name)
end)

DevProductPurchase.OnServerEvent:Connect(function(player)
	mps:PromptProductPurchase(player, productID)
	local function processReceipt(receiptInfo)
		
		local person = Players:GetPlayerByUserId(receiptInfo.PlayerId)
		if not person then
			return Enum.ProductPurchaseDecision.NotProcessedYet
		end
		if receiptInfo.ProductId == productID then
			if person then
				print("Purchased")
				local newTicket = ReplicatedStorage.Tickets.Boosted:Clone()
				newTicket.Parent = game.Workspace:FindFirstChild(player.Name)
			end
		end
		return Enum.ProductPurchaseDecision.PurchaseGranted
	end
end)

Local Script

local regular = script.Parent.Regular
local vip = script.Parent.VIP
local closed = script.Parent.Close
local boosted = script.Parent.Boosted
local plr = game.Players.LocalPlayer
local detector = workspace.TicketGuy2.ClickDetector 



boosted.MouseButton1Click:Connect(function()
	game.ReplicatedStorage.DevProductPurchase:FireServer()
end)

regular.MouseButton1Click:Connect(function()
	if plr.leaderstats.SneakyPoints.Value > 4 then
		plr.leaderstats.SneakyPoints.Value = plr.leaderstats.SneakyPoints.Value - 5
		print("Points Deducted")
		game.ReplicatedStorage.GiveRegular:FireServer()
		print("Remote Event Fired")
	end
end)

vip.MouseButton1Click:Connect(function()
	
end)

closed.MouseButton1Click:Connect(function()
	script.Parent.Visible = false
end)

detector.MouseClick:Connect(function()
	script.Parent.Visible = true
end)

I also renamed the remote event to DevProductPurchase

I don’t think you called the Process receipt function

1 Like

Adding on to @xurmx, the ProcessReceipt should be its own function outside of the Dev Product function and make sure to add the code below to make a connection.

MarketplaceService.ProcessReceipt = processReceipt

this can only be done once by one script on the server!

You didn’t set the callback so just do

mps.ProccessReciept = function

I know,(thanks for explaining though) it works now, probably should have said that!

That’s awesome happy scripting! :call_me_hand:

1 Like