Buy-Shirt Button not working

So I’m trying to make a buy shirt button where when you click the button,the purchase thing will appear,but it doesn’t work,here’s my script: (a localscript located in the frame of the button)

local CLICK_BLOCK = script.Parent.Shirt1

local ITEM_ID = 6321307072 --ID number of shirt

local Click = Instance.new("ClickDetector",CLICK_BLOCK)

Click.MouseClick:connect(function(p)

game:GetService("MarketplaceService"):PromptPurchase(p,ITEM_ID)

end)
1 Like

If the frame is in workspace, then the localscript cannot work, it must be a regular script

1 Like

it still doesn’t work
if you need more info,the button is an image button

Why is an image button controlling a clickdetector? Make the ClickDetector manually from studio and put this script in it

local MarketplaceService = game:GetService("MarketplaceService")

local ITEM_ID = 6321307072 --ID number of shirt

local Click = script.Parent

Click.MouseClick:Connect(function(player)
	MarketplaceService:PromptPurchase(player,ITEM_ID)
end)

Your issue might be relating to something else if it’s a SurfaceGui, but in the end you should just do this instead as it’s the simplest way to do what is required in your case

do I put it in the same place as where I put my original script?
If yes,it still doesn’t work

As I said, put a clickdetector where you want it to detect clicks, in your case, in the Shirt1 part, and then put the script I sent inside of that newly added clickdetector as a regular script

Didn’t work,the click detector option is greyed out fyi but did what you say anyways

Hang on is Shirt1 an imagebutton? Clickdetectors don’t work there? May I see your explorer to see how everything is set up so I can see what may be the solution

Screen Shot 2021-04-28 at 19.44.59

Put this code as a localscript in Shirt1

local MarketplaceService = game:GetService("MarketplaceService")
local Players = game:GetService("Players")

local ITEM_ID = 6321307072 --ID number of shirt

local player = Players.LocalPlayer

local button = script.Parent

button.MouseButton1Down:Connect(function()
	MarketplaceService:PromptPurchase(player,ITEM_ID)
end)

You just need to use an event that handles mouse input for GuiButtons, in this case, MouseButton1Down

1 Like

It worked again!
Thank You agan!

lol

1 Like

this* didnt work i tried local script

local MarketplaceService = game:GetService(“MarketplaceService”)

local Players = game:GetService(“Players”)

local ITEM_ID = 11269961776 --ID number of shirt

local player = Players.LocalPlayer

local button = script.Parent

button.MouseButton1Down:Connect(function()

MarketplaceService:PromptPurchase(player,ITEM_ID)

end)