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

Shop GUI gamepass script wont give me my gamepass item?

Asked by 4 years ago

hello, I'm trying to create a gamepass shop using a regular script, but multiple attempts have been made and I can't get it to work. Here is the script:

local tool = game.Lighting:findFirstChild("LinkedRocketLauncher")
local button = script.Parent
local player = game.Players.LocalPlayer
local Value = script.Parent.Gamepass

function buy()
if button.MouseButton1Click:connect(function()
    game:GetService("MarketplaceService"):PromptGamePassPurchase(player, Value.Value)
local a = tool:clone()
a.Parent = player.Backpack
local b = tool:clone()
b.Parent = player.StarterGear
end
end

script.Parent.MouseButton1Down:connect(buy)

please help.

1 answer

Log in to vote
0
Answered by 4 years ago

Try this script if it works:

local tool = game.Lighting:findFirstChild("LinkedRocketLauncher")
local id = -- your gamepass id
local player = game.Players.LocalPlayer

script.Parent.MouseButton1Down:Connect(function(buy)
    game:GetService("MarketplaceService"):PromptGamePassPurchase(player, id)
end)

local MPS = game:GetService("MarketplaceService")

MPS.PromptGamePassPurchaseFinished:Connect(function(plr,id,bought)
    if id == -- your id
 and bought then
         local a = tool:clone() 
a.Parent = player.Backpack  
local b = tool:clone()
    b.Parent = player.StarterGear
    end
end)
Ad

Answer this question