Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Prompting a product purchase not working is a surfaceGui?

Asked by 3 years ago

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

Log in to vote
0
Answered by
zadobyte 692 Moderation Voter
3 years ago
Edited 3 years ago

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

0
Damn, I'm such a slow typer. raid6n 2196 — 3y
0
hehe, i just had a smaller answer, dw dw zadobyte 692 — 3y
Ad
Log in to vote
0
Answered by
raid6n 2196 Moderation Voter Community Moderator
3 years ago
Edited 3 years ago

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
)
0
i am wanting to put this product purchase on a surface gui though, so wouldn't local player not work? catsalt29 57 — 3y
0
its a server script inside a surfacegui so you cant do localplayer zadobyte 692 — 3y

Answer this question