Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Prompting a product purchase not working is a surfaceGui?

code:(inside of TextButton parent is surfacegui)

script.Parent.MouseButton1Click:Connect(function(player)
	local productId = 1086368295
		game:GetService("MarketplaceService"):PromptProductPurchase(player, productId)
	end)

error "- MarketplaceService:PromptProductPurchase() player should be of type Player, but is of type nil"

2 answers

MouseButton1Click doesn't have the player as a parameter. You should probably get the player through playeradded instead.

2 comments

0

Damn, I'm such a slow typer.

0

hehe, i just had a smaller answer, dw dw

Okay, so there are no parameters of MousebUtton1Click, instead just make a variable like this:

local player = game.Players.LocalPlayer

Code:

script.Parent.MouseButton1Click:Connect(
    function()
        local player = game.Players.LocalPlayer
        local productId = 1086368295
        game:GetService("MarketplaceService"):PromptProductPurchase(player, productId)
    end
)

2 comments

0

i am wanting to put this product purchase on a surface gui though, so wouldn't local player not work?

0

its a server script inside a surfacegui so you cant do localplayer

This discussion is preserved as it was. New answers, comments, and votes are closed.