Sorry, I have been creating a lot of topics lately but I am learning to script so yea you run into loads of errors when you are learning. Well, my dev product script is not giving the product even after the purchase is successful. Here are the scripts
DevProduct Prompter Script
local MarketPlaceService = game:GetService("MarketplaceService")
local Players = game:GetService("Players")
local productID = 1075471951
local player = game.Players.LocalPlayer
wait (3)
MarketPlaceService:PromptProductPurchase(player , productID)
____________________________________________________________________________
The DevProductHandeler (This is where I am getting the error)
local MarketPlaceService = game:GetService("MarketplaceService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local gun = game.ReplicatedStorage:WaitForChild("ClassicPaintballGun")
local players = game:GetService("Players")
local productID = 1075471951
local function processReceipt(receiptInfo)
local player = players:GetPlayerByUserId(receiptInfo.playerId)
if not player then
--the player probably left the game
--If they come back ,the callback will be called again
return Enum.ProductPurchaseDecision.NotProcessedYet
end
if player then
--what do u want the devproduct to do
local char = game.Workspace:FindFirstChild(player.Name)
local gunClone = gun.clone()
gunClone.Name = gun
gunClone.Parent = char
end
return Enum.ProductPurchaseDecision.PurchaseGranted
end
--Set callback
MarketPlaceService.ProcessReceipt = processReceipt()
local MarketplaceService = game:GetService("MarketplaceService")
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Gun = ReplicatedStorage:WaitForChild("ClassicPaintballGun")
MarketplaceService.ProcessReceipt = function(receiptInfo)
if receiptInfo.ProductId == 1075471951 then
local Player = Players:GetPlayerByUserId(receiptInfo.PlayerId) -- Apparently its PlayerId lol sorry.
if Player then
repeat wait() until workspace:FindFirstChild(Player.Name) -- Just for safety.
local Character = workspace[Player.Name]
local gun = Gun:Clone()
gun.Parent = Player:WaitForChild("Backpack") -- Instead of the Character, he has it in his inventory.
return Enum.ProductPurchaseDecision.PurchaseGranted
else
return Enum.ProductPurchaseDecision.NotProcessedYet
end
end
end
This should work, i hope you understand everything. I had no problems while testing it.