Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

I need help with my gamepass because the id's not working. Can someone help?

I have a button with this script, and it says this item isn't for sale when I try to buy it.

local CLICK_BLOCK = script.Parent
local ITEM_ID = 5347758

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

Click.MouseClick:connect(function(p)
game:GetService("MarketplaceService"):PromptPurchase(p,ITEM_ID)
end)

3 comments

0

I made sure the id was right, and it still doesnt work.

0

try configuring the Item, making sure that it is for sale

0

I did that a lot, and its a gamepass.

1 answer

✓ Accepted answer

###Gamepasses vs Assets

Over the summer, roblox changed how gamepasses work. They made them their own seperate entity, rather then an asset. This means that they had to create new methods, and tinker old ones. This is included here.

PromptPurchase takes an Asset Id (Hat, gear, etc). Instead, we must use a new method calledPromptGamePassPurchase

###Deprecated Code

connect is deprecated. Instead, use Connect

The 2nd parameter of Instance.new(X, Y) (the Y), is deprecated. Instead use .Parent.

###Solution

local CLICK_BLOCK = script.Parent
local ITEM_ID = 5347758

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

Click.MouseClick:Connect(function(p)
	game:GetService("MarketplaceService"):PromptGamePassPurchase(p,ITEM_ID) 
end)

##Wiki Links

PromptGamePassPurchase

3 comments

0

It gave me an error, saying unable to cast value to Object.

0

Try now. Had a typo :facepalm:

0

Thanks you so much! It works!

This discussion is preserved as it was. New answers, comments, and votes are closed.