Why is this script not working?

Hello. I am trying to make a button that when clicked, it prompts a accessory purchase.

This is what I have, but it doesnt work.

local ITEM_ID = 7169551212 -- ID

script.Parent.MouseButton1Click:Connect(function(p)
	game:GetService("MarketplaceService"):PromptPurchase(p,ITEM_ID)
end)

plz help

1 Like

Hello,

You’ve only forgotten the plr.UserId, here:

local plr = game:GetService("Players").LocalPlayer
local ITEM_ID = 7169551212 -- ID
script.Parent.MouseButton1Down:Connect(function()
	game:GetService("MarketplaceService"):PromptPurchase(plr.UserId,ITEM_ID)
end)

Hello. Thank you for responding. It still isnt working for me idk why but this is what output has to say

you didn’t put the id variable as the second argument…

local player : player = game:GetService("Players").LocalPlayer
local id : number = 7169551212 -- ID
script.Parent.MouseButton1Down:Connect(function()
	game:GetService("MarketplaceService"):PromptPurchase(player.UserId, id)
end)

hi thx for respnoding. it still says this idk what is wrong

error is unable to cast value to object…
oops

local player = game:GetService("Players").LocalPlayer
local id : number = 7169551212 -- ID
script.Parent.MouseButton1Down:Connect(function()
	game:GetService("MarketplaceService"):PromptPurchase(player.UserId, id)
end)

im still getting this, idk what is wrong


maybe something wrong that isnt the script? idk

local player = game:GetService("Players").LocalPlayer
local id = 7169551212 -- ID
script.Parent.MouseButton1Down:Connect(function()
	game:GetService("MarketplaceService"):PromptPurchase(player, id)
end)

why is it still happening is it something else wrong and not the script or like is there a different script i can use for this to work and just throw this other script away

dawg remove the .UserId ion know

1 Like

also make sure dis a local script not server script

lol this is the thing that made it work thx

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