It is already Local script
1 | local MarketplaceService = Game:GetService( "MarketplaceService" ) |
2 | local buyButton = game.Workspace.BuyButton.SurfaceGui.TextButton |
3 | local productId = 21248921 |
4 |
5 | buyButton.MouseButton 1 Click:connect( function () |
6 | MarketplaceService:PromptProductPurchase(player, productId) |
7 | end ) |
player
is not a globally defined variable in the default environment; you have to access the client's player using game.Players.LocalPlayer