#Problem
Okay, so for my game I've made a bank where you can buy devproducts, and each transaction you get some coins.
BUT, i got this error;
Players.maxpax2009.PlayerGui.BankGui.Prompters.ProductPromptHandler:13: attempt to index number with 'PlayerId'
It's on line 13
Why tho, it should work completely fine!
#Code
local MarketPlaceService = game:GetService("MarketplaceService")
local Players = game:GetService("Players")
local Ids = {
["Transaction1"] = {id = 1230432, price = 200},
["Transaction2"] = {id = 12012, price = 500},
["Transaction3"] = {id = 12313, price = 2000},
["Transaction4"] = {id = 123323, price = 5000}
}
local function ProcessReceipt(receiptInfo, price)
local player = Players:GetPlayerByUserId(receiptInfo.PlayerId)
if not player then
-- if the player probably left the game
return Enum.ProductPurchaseDecision.NotProcessedYet
end
if player then
-- what you want the devproduct to do
player.leaderstats.Cash.Value = player.leaderstats.Cash.Value + price
end
return Enum.ProductPurchaseDecision.PurchaseGranted
end
for i, v in pairs(Ids) do
for _, x in pairs(script.Parent.Parent.ShopFrame:GetChildren()) do
local found = false
if x.Name == i then
found = true
x.ImageButton.Activated:Connect(function()
MarketPlaceService:PromptProductPurchase(Players.LocalPlayer, v.id)
MarketPlaceService.ProcessReceipt = ProcessReceipt(v.price)
end)
end
end
end

1 comment
Are you secretly maxpax2009