Help with a button that prompts a t-shirt purchase

please help, my script isn’t working for some reason, I am sure it is correct.

local onClicked = script.Parent

local item_id = "6493716017" -- DONT FORGET TO SET THIS OKAY KYE

onClicked.MouseButton1Click:Connect(function()

game:GetService("MarketplaceService"):PromptPurchase(item_id)

end)
1 Like

Sometimes MouseButton1Click does not work maybe you could try MouseButton1Down?

I tried it and it doesn’t work, I don’t know how to fix it!

you need to include the player you want to prompt to

game:GetService(“MarketplaceService”):PromptPurchase(player,item_id)
2 Likes

You can’t make the id a quote it has to be just numbers

Do this
local onClicked = script.Parent

local item_id = 6493716017 – DONT FORGET TO SET THIS OKAY KYE

onClicked.MouseButton1Click:Connect(function(player)

game:GetService(“MarketplaceService”):PromptPurchase(player, item_id)

end)

You forgot to define who to prompt the purchase to, which would be the player, which is why it isn’t working

MouseButton1Click does not define player.

@vvKyee Use a local script to detect the MouseButton1Click inside the GUI. You should then use a RemoteEvent and Fire it when the button is clicked and it will prompt you from a ServerSide script.

Example:

local onClicked = script.Parent

local item_id = "6493716017" -- DONT FORGET TO SET THIS OKAY KYE

onClicked.MouseButton1Click:Connect(function()

RemoteEvent:FireServer(item_id)

end)

Server:

RemoteEvent.OnServerEvent:Connect(function(Player,Product)
    game:GetService("MarketplaceService"):PromptPurchase(Player,Product)
end)

you dont need a remote event since you could just define the local player by
local player = game.player.localplayer

plus i thought he meant a button as a physical part button in workspace