I was trying to make a script for developer products and this error pops up when I click the buy button
- attempt to call a nil value
- MarketplaceService:PromptProductPurchase() player should be of type Player, but is of type nil
- Stack Begin
- Script 'Players.HenriqueHome31.PlayerGui.GameShopGui.BoneShop.Bone1.buy.Script', Line 5
- Stack End
this is the button script:
local productId = 639390080
local player = game.Players.LocalPlayer
script.Parent.MouseButton1Click:connect(function()
game:GetService("MarketplaceService"):PromptProductPurchase(player, productId)
end)
script.Parent.MouseButton1Click:Connect()
and there is the Server ScriptService script which is this
local MarketplaceService = game:GetService("MarketplaceService")
local PointsID, Points2ID, Points3ID, Points4ID ,Points5ID = 639390080, 639411154, 639411602, 639411987, 639412394
local PurchaseHistory = game:GetService("DataStoreService"):GetDataStore("PurchaseHistory")
MarketplaceService.ProcessReceipt = function(receiptInfo)
for i, player in ipairs(game.Players:GetChildren()) do
if player.userId == receiptInfo.PlayerId then
if receiptInfo.ProductId == PointsID then
player.leaderstats.Bones.Value = player.leaderstats.Bones.Value + 500
end
end
end
for i, player in ipairs(game.Players:GetChildren()) do
if player.userId == receiptInfo.PlayerId then
if receiptInfo.ProductId == Points2ID then
player.leaderstats.Bones.Value = player.leaderstats.Bones.Value + 10000
end
end
end
for i, player in ipairs(game.Players:GetChildren()) do
if player.userId == receiptInfo.PlayerId then
if receiptInfo.ProductId == Points3ID then
player.leaderstats.Bones.Value = player.leaderstats.Bones.Value + 100000
end
end
end
for i, player in ipairs(game.Players:GetChildren()) do
if player.userId == receiptInfo.PlayerId then
if receiptInfo.ProductId == Points4ID then
player.leaderstats.Bones.Value = player.leaderstats.Bones.Value + 500000
end
end
end
for i, player in ipairs(game.Players:GetChildren()) do
if player.userId == receiptInfo.PlayerId then
if receiptInfo.ProductId == Points5ID then
player.leaderstats.Bones.Value = player.leaderstats.Bones.Value + 2000000
end
end
end
local playerProductKey = "player_" .. receiptInfo.PlayerId .. "_purchase_" .. receiptInfo.PurchaseId
PurchaseHistory:IncrementAsync(playerProductKey, 1)
return Enum.ProductPurchaseDecision.PurchaseGranted
end
I have no idea what it is, if it's the button or SSS script can anyone help me with this?
