code:(inside of TextButton parent is surfacegui)
1 | script.Parent.MouseButton 1 Click:Connect( function (player) |
2 | local productId = 1086368295 |
3 | game:GetService( "MarketplaceService" ):PromptProductPurchase(player, productId) |
4 | end ) |
error "- MarketplaceService:PromptProductPurchase() player should be of type Player, but is of type nil"
MouseButton1Click doesn't have the player as a parameter. You should probably get the player through playeradded instead.
Okay, so there are no parameters of MousebUtton1Click, instead just make a variable like this:
local player = game.Players.LocalPlayer
Code:
1 | script.Parent.MouseButton 1 Click:Connect( |
2 | function () |
3 | local player = game.Players.LocalPlayer |
4 | local productId = 1086368295 |
5 | game:GetService( "MarketplaceService" ):PromptProductPurchase(player, productId) |
6 | end |
7 | ) |