DevProduct Not Working?

Old Issue

I want to be able to have my players purchase an item that gets given to you. The item giving works fine, but the Devproduct side doesn’t.
The player gets charged, but the devproduct doesn’t actually function.

local MarketPlaceService = game:GetService("MarketplaceService")
local Players = game:GetService("Players")
local rep = game:GetService("ReplicatedStorage")
local weapons = rep.Weapons.DevProducts
local remote = rep.RemoteEvent

local wp = nil

-- purchases

local ProductFunctions = {}

ProductFunctions[1275427692] = function(player)
	local wp = weapons.Nuke:Clone()
	wp.Parent = player:WaitForChild("Backpack")
end

MarketPlaceService.ProcessReceipt = function(info)
	local Player = Players:GetPlayerByUserId(info.PlayerId)
	local Product = info.PromptId

	if not Player then
		return Enum.ProductPurchaseDecision.NotProcessedYet
	end

	local success, err = pcall(ProductFunctions[Product],Player)
	if not success then
		warn('error')
		return Enum.ProductPurchaseDecision.NotProcessedYet
	end

	return Enum.ProductPurchaseDecision.PurchaseGranted
end

-- prompts
remote.PromptNuke.OnServerEvent:Connect(function(player)
	MarketPlaceService:PromptProductPurchase(player, 1275427692)
end)

When purchased, my warning("error") happens, and the item isn’t given.

My New issue is an error that pops up when the Developer Product is purchased
Error: Unable to cast value to Object - Server - Script:25
Code:

local rep = game:GetService("ReplicatedStorage")
local weapons = rep.Weapons.DevProducts
local remote = rep.RemoteEvent

-- purchases

local ProductFunctions = {}

ProductFunctions[1275427692] = function(Player)
   remote.URLgive:FireClient(Player)
end

MarketPlaceService.ProcessReceipt = function(info)
   local Player = Players:GetPlayerByUserId(info.PlayerId)
   local Product = info.ProductId

   if not Player then
   	return Enum.ProductPurchaseDecision.NotProcessedYet
   end

   local success, err = pcall(ProductFunctions[Product], info, Player)
   if not success then
   	print(err)
   	return Enum.ProductPurchaseDecision.NotProcessedYet
   end

   return Enum.ProductPurchaseDecision.PurchaseGranted
end

-- prompts
remote.PromptNuke.OnServerEvent:Connect(function(player)
   MarketPlaceService:PromptProductPurchase(player, 1275427692)
end)```

Try instead:

local success, err = pcall(ProductFunctions[Product], info, Player)

Also I believe it’s ProductId, not PromptId

Edit:
Also instead of printing “error” you should do print(err) to get the actual output error message

Just wanted to let you know about something called OBS, it’s a really good free recording/streaming softwares; i’d recommend getting it because the video you uploaded is very choppy.

I used OBS before, and as someone with a 3-4gb ram computer, it lags my pc to the point of freezing it sometimes. The recordings also are laggy. Vokoscreen at least doesn’t freeze my pc

1 Like

Now the new error is
Unable to cast value to Object - Server - Script:25
Updated Script:

local Players = game:GetService("Players")
local rep = game:GetService("ReplicatedStorage")
local weapons = rep.Weapons.DevProducts
local remote = rep.RemoteEvent

-- purchases

local ProductFunctions = {}

ProductFunctions[1275427692] = function(Player)
	remote.URLgive:FireClient(Player)
end

MarketPlaceService.ProcessReceipt = function(info)
	local Player = Players:GetPlayerByUserId(info.PlayerId)
	local Product = info.ProductId

	if not Player then
		return Enum.ProductPurchaseDecision.NotProcessedYet
	end

	local success, err = pcall(ProductFunctions[Product], info, Player)
	if not success then
		print(err)
		return Enum.ProductPurchaseDecision.NotProcessedYet
	end

	return Enum.ProductPurchaseDecision.PurchaseGranted
end

-- prompts
remote.PromptNuke.OnServerEvent:Connect(function(player)
	MarketPlaceService:PromptProductPurchase(player, 1275427692)
end)```