Prompt Shirt Purchase Issues

How would I script a model that when you click it and you click buy and its will prompt a purchase thingy?

Its a local script
For now :

Code I used

local plr = game.Players.LocalPlayer
local chr = plr.Character or plr.CharacterAdded:Wait()

local MSS = game:GetService("MarketplaceService")

for i,v in pairs(workspace.Clothing:GetChildren()) do
	if v:IsA("Model") then
		local clickDetector = Instance.new("ClickDetector",v)
		clickDetector.MaxActivationDistance = 16
		
		local billBoardGUI = script.BillboardGui:Clone()
		billBoardGUI.Parent = script.Parent
		billBoardGUI.Adornee = v.HumanoidRootPart
		
		local tried = false
		billBoardGUI.TryButton.Activated:Connect(function()
			if tried == false then
				local shirt = chr:FindFirstChildWhichIsA("Shirt")
				if shirt then
					tried = true
					local currentTemplate = chr:FindFirstChildWhichIsA("Shirt").ShirtTemplate
					shirt.ShirtTemplate = v:FindFirstChildWhichIsA("Shirt").ShirtTemplate
					repeat wait() until tried == false
					shirt.ShirtTemplate = currentTemplate
				end
			else
				tried = false
			end
		end)
		
		billBoardGUI.BuyButton.Activated:Connect(function()
			game:GetService("MarketplaceService"):PromptPurchase(plr, v:FindFirstChild("AssetId").Value)
		end)
		
		local turnBool = false
		clickDetector.MouseClick:Connect(function()
			if turnBool == false then
				turnBool = true
				billBoardGUI.Enabled = true
			else
				turnBool = false
				billBoardGUI.Enabled = false
			end
		end)
		
	end
end

for i,v in pairs(workspace.Pants:GetChildren()) do
	if v:IsA("Model") then
		local clickDetector = Instance.new("ClickDetector",v)
		clickDetector.MaxActivationDistance = 16

		local billBoardGUI = script.BillboardGui:Clone()
		billBoardGUI.Parent = script.Parent
		billBoardGUI.Adornee = v.HumanoidRootPart

		local tried = false
		billBoardGUI.TryButton.Activated:Connect(function()
			if tried == false then
				local shirt = chr:FindFirstChildWhichIsA("Pants")
				if shirt then
					tried = true
					local currentTemplate = chr:FindFirstChildWhichIsA("Pants").PantsTemplate
					shirt.PantsTemplate = v:FindFirstChildWhichIsA("Pants").PantsTemplate
					repeat wait() until tried == false
					shirt.PantsTemplate = currentTemplate
				end
			else
				tried = false
			end
		end)

		billBoardGUI.BuyButton.Activated:Connect(function()
			local Success2, Result2 = pcall(function()	
				return game:GetService("MarketplaceService"):GetProductInfo(v:FindFirstChild("AssetId").Value, Enum.InfoType.Asset)
			end)

			if Success2 and Result2 then
				MSS:PromptPurchase(game.Players.LocalPlayer,Result2.ProductId)
			end
		end)

		local turnBool = false
		clickDetector.MouseClick:Connect(function()
			if turnBool == false then
				turnBool = true
				billBoardGUI.Enabled = true
			else
				turnBool = false
				billBoardGUI.Enabled = false
			end
		end)

	end
end

AssetId
image

How did you get the Asset Id, and like where. I know this sounds like a dumb question. But there are different Ids for different things for game passes and developer Products, and possibly other Products as well

1 Like

Got the Assetid in the ShirtId, I tried getting it with the productId but Its still dosent prompt . I trying to prompt the Shirt and Pants Purchase

Are you trying to get this shirt? This Shirt

If so, It is giving you the correct error. As you cannot buy it, as it is offsale

EXATCTLY,Iā€™m way too dumb but thank you for that

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.