I have this surface gui with buttons on it and it seems to not be working. The output says these errors,"
MarketplaceService:PromptProductPurchase() player should be of type Player, but is of type Players
MouseButton1Click is not a valid member of TextLabel “Players.Itsjacobiward.PlayerGui.ThanksMessage.TextLabel.TextLabel”
Workspace.Tithes & Offering.SurfaceGui.Frame.TextButton.Purchase:8: attempt to index nil with ‘PlayerId’
Here’s my code for the things.
This is the Text button script
"local MarketplaceService = game:GetService(“MarketplaceService”)
local players = game:GetService(“Players”)
local productID = 1209398991
local function processReceipt (receiptInfo)
local player = players:GetPlayerByUserId(receiptInfo.PlayerId)
if not player then
-- The player proably left the game
-- If they come back, the callback will be called again
return Enum.ProductPurchaseDecision.NotProcessedYet
end
if player then
-- What happens when purchased
game.StarterGui.ThanksMessage.Enabled = true
print(player.Name.. " just bought " .. receiptInfo.ProductId)
end
return Enum.ProductPurchaseDecision.PurchaseGranted
end
– Set callback
MarketplaceService.ProcessReceipt = processReceipt()"
Here’s the local script
"local MarketplaceService = game:GetService(“MarketplaceService”)
local Players = game:GetService(“Players”)
local productID = 1209398991
local player = game.Players.LocalPlayer
Should be MarketplaceService.ProcessReceipt = processReceipt, you have an extra pair of parentheses which is going to cause an issue where you’re trying to assign a non-function value to the callback
2- The reason it’s giving that error is because you’re trying to pass the players service to the prompt product purchase func, to fix it:
local MarketplaceService = game:GetService(“MarketplaceService”)
local Players = game:GetService(“Players”)
local productID = 1209398991
local player = Players.LocalPlayer
MarketplaceService:PromptProductPurchase(player, productID)
I’m not getting a error anymore but I do have a issue when I start the game I get promoted to purchase and when I attempt to press the button they don’t work