When I attempt to run the code for prompting a developer product purchase I end up getting this in the output:
1 | 07 : 57 : 29.741 - MarketplaceService:PromptProductPurchase() player should be of type Player, but is of type nil |
2 | 07 : 57 : 29.743 - Stack Begin |
3 | 07 : 57 : 29.744 - Script 'Workspace.Gifts.Display.SurfaceGui.Script1' , Line 9 |
4 | 07 : 57 : 29.745 - Stack End |
I have no idea how to fix this and I have tried several things. Here's the code I'm trying to use as well:
01 | local MarketplaceService = game:GetService( "MarketplaceService" ) |
02 | local Players = game:GetService( "Players" ) |
03 |
04 | local productID = 965613937 |
05 |
06 | local function promptPurchase() |
07 | local player = Players.LocalPlayer |
08 | MarketplaceService:PromptProductPurchase(player, productID) |
09 | end |
10 |
11 | script.Parent.Small.MouseButton 1 Click:Connect(promptPurchase) |
EDIT: I just realize your script work, but it need some change:
01 | local MarketplaceService = game:GetService( "MarketplaceService" ) |
02 | local Players = game:GetService( "Players" ) |
03 |
04 | local productID = 965613937 |
05 |
06 | local function promptPurchase() |
07 | local player = Players.LocalPlayer |
08 | MarketplaceService:PromptProductPurchase(player, productID) |
09 | end |
10 |
11 | game.Workspace.Gifts.Display.SurfaceGui.Small.MouseButton 1 Click:Connect(promptPurchase) |
Change the script to LocalScript and put it in StarterPlayerScripts.
I already made a script... Why not you just try this:
1 | Button.MouseButton 1 Click:Connect( function (promptPurchase) |
2 | local MarketplaceService = game:GetService( "MarketplaceService" ) |
3 | local Players = game:GetService( "Players" ) |
4 | local productID = 965836984 |
5 | local player = Players.LocalPlayer |
6 | MarketplaceService:PromptProductPurchase(player, productID) |
7 | end ) |
It works fine for me, tell me if it works