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

Surface GUI and shop?

Asked by
Scootakip 299 Moderation Voter
8 years ago
market = game:GetService("MarketplaceService")
val = script.item
scanning = true
while scanning do
    asset = market:GetProductInfo(val.Value)
--  print("scanning ID ", val.Value)
    if asset.AssetTypeId == 11 or  asset.AssetTypeId == 13 then
        scanning = false
--      print("ID:",val.Value," is a clothing item! ID successful!")
    else
        val.Value = val.Value +1
--      print("ID failed trying ",val.Value)
    end
end
script.Parent.MouseButton1Click:connect(function(plr)
    market:PromptPurchase(plr, val.Value)
end)

This script always says the plr on line 22 is nil. Help? This is a script inside of a TextButton Surface GUI.

1 answer

Log in to vote
0
Answered by 8 years ago

Plr can't be called on to identify the actual player. Here is what I did. This is from one of my games, which works correctly.

productId = 30631246


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

if script.Parent.Parent.Visible == true then
    game:GetService("UserInputService").InputBegan:connect(function(input)
        if input.UserInputType == Enum.UserInputType.Gamepad1 then
            if input.KeyCode == Enum.KeyCode.ButtonA then
                game:GetService("MarketplaceService"):PromptProductPurchase(game.Players.LocalPlayer, productId)
            end
        end
    end)
end
0
Now when I clicked it, nothing happens. No error. Scootakip 299 — 8y
0
It's a local script, and where is it? JamesLWalker 297 — 8y
0
It's a local script inside of the Text Button. The text button is in a surface gui, not a screen gui. Scootakip 299 — 8y
0
Oh, well. That's embarrassing. This will work with a screen GUI, to my knowledge. Not yet surface gui. JamesLWalker 297 — 8y
Ad

Answer this question