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

What did I do wrong in my MarketplaceService script?

I don't know what I did wrong, it won't work, here is the script;

script.Parent.MouseButton1Click:connect(function()
game:GetService("MarketplaceService"):PromptPurchase(game.Players.LocalPlayer, 161160031)
end)

The Output said MarketplaceService:PromptPurchase() player should be of type Player, but is of type nil, but I don't know what it means by that, what have I done/what did I do wrong?

3 answers

You need to put it in a normal script:

ID = 000--Relpace with ID

script.Parent.MouseButton1Click:connect(function(player)
game:GetService("MarketplaceService"):PromptPurchase(player,ID)end)

1 comment

0

Still isn't working for some reason, and isn't giving an error in the Output anymore, is the service Unavailable? :c

script.Parent.MouseButton1Click:connect(function()
game:GetService("MarketplaceService"):PromptPurchase(script.Parent.Parent.Parent.Parent, 161160031) --I am just going to assume the parent properties go like so from script Button > ScreenGui > PlayerGui > Player
end)

The problem fahmisak has was, MouseButton1Click didn't return the player, in fact it doesn't return anything. Though I am just assuming you are using a classic ScreenGui rather than a SurfaceGui since you used a local script. Anyways, I think the script is fixed.

2 comments

0

Eerm, how come it works in my game??

0

Depends, are you using the surface gui with the script, because I think ROBLOX modified the Surface Gui events so it can track if you clicked it or not.

I found the post by M39a9am3R helpful for my ingame currency purchase GUI except how would I make it work with developer products? When I use it for my developer product, my developer product seems to share an ID with a "Happy Home in Robloxia" place...

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