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