local MarketplaceService = game:GetService("MarketplaceService")
local ds = game:GetService("DataStoreService"):GetDataStore("countdowncreditservice")
local productID = 20518668
local buy = script.Parent
buy.MouseButton1Click:connect(function()
game:GetService("MarketplaceService"):PromptProductPurchase(game.Players.LocalPlayer, productID)
end)
MarketplaceService.ProcessReceipt = function(receiptInfo)
for i, player in ipairs(game.Players:GetChildren()) do
if player.userId == receiptInfo.PlayerId then
if receiptInfo.ProductId == productID then
player.statistics.credits.Value = player.statistics.credits.Value + 1
local key = "plyr-"..player.userId
local savedvalue = {player.statistics.credits.Value}
ds:SetAsync(key, savedvalue)
return Enum.ProductPurchaseDecision.PurchaseGranted
end
end
end
end
This is in a normal script within the player's StarterGui in a GUI.
Here's my error: MarketplaceService.PromptProductPurchase() player should be of type Player but is of type nil
This is pertaining to line 8, game:GetService("MarketplaceService"):PromptProductPurchase(game.Players.LocalPlayer, productID).
Does anybody know what the problem is?
