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

How to make a proper game pass script?

Asked by 2 years ago
local CLICK_BLOCK = script.Parent
local ITEM_ID = 17982057 -- Your Developer Product ID (e.g. 116824324). If you don't know where you can get your ID, then go to this link: http://pic.supersgames.rf.gd/uploads/manual/devproid.png (ID marked in yellow).

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

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

this is a script that is supposed to make it so when a player presses a button a ui will pop up so the player can buy my game pass but the UI won't pop up when you click on it how can we fix this?

And of course, i got this from a tutorial lol

0
The script seems to be working for me. Are you using a LocalScript or a regular Script, and where are you putting the script? SpeedySixTen 50 — 2y
0
regular script it's simply in a part with an image button dylancrazy88 20 — 2y

1 answer

Log in to vote
0
Answered by 2 years ago
Edited 2 years ago

Put a local script in the button and type this

edit: btw if you use a gamepass you made, it wont work for you, use a different gamepass not made by you that you bought so you can test it. if you finish the game, change it back so you can get robux by it

local ID = "0000000" -- add your gamepass ID here
script.Parent.EnterProduct.Buy.MouseButton1Click:Connect(function()
    game:GetService("MarketplaceService"):PromptGamePassPurchase(game.Players.LocalPlayer, ID)
end)

After purchasing, if you want something to happen by buying it, put this script in StarterGui and make it a local script. (btw idk if you have to put it in StarterGui, thats just what im doing)

local ID = "0000000" -- add your gamepass ID here
while wait() do
    if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(game.Players.LocalPlayer.UserId,ID then
        -- do whatever you want
    else
        -- undo it for anti-cheat reasons. example give the player a speed boost, replace it with the regular run speed (16)
    end
end
0
i used your script and it won't let me click on the button dylancrazy88 20 — 2y
Ad

Answer this question