Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 5 years ago

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)
0
I made sure the id was right, and it still doesnt work. protectiverobos -50 — 5y
0
try configuring the Item, making sure that it is for sale blockletssky 0 — 5y
0
I did that a lot, and its a gamepass. protectiverobos -50 — 5y

1 answer

Log in to vote
0
Answered by
green271 635 Moderation Voter
5 years ago
Edited 5 years ago

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

0
It gave me an error, saying unable to cast value to Object. protectiverobos -50 — 5y
0
Try now. Had a typo :facepalm: green271 635 — 5y
0
Thanks you so much! It works! protectiverobos -50 — 5y
Ad

Answer this question