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

Surface GUI and shop?

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

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

4 comments

0

Now when I clicked it, nothing happens. No error.

0

It's a local script, and where is it?

0

It's a local script inside of the Text Button. The text button is in a surface gui, not a screen gui.

0

Oh, well. That's embarrassing. This will work with a screen GUI, to my knowledge. Not yet surface gui.

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