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)```