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

Shop GUI gamepass script wont give me my gamepass item?

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

✓ Accepted answer

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)

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