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.
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