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

How do I give a player a tool after purchasing a game pass in-game?

Asked by 6 years ago

I would like to set up an in-game gamepass purchase that gives you the tool after buying the game pass in-game. This would be very convenient for players purchasing game passes, because implementing the current script I have right now would require them to wait for the server to restart.

Here is what I have

local Id = 626438744 --Change this number to your Game Pass ID.

script.Parent.ClickDetector.MouseClick:connect(function(player)
    game:GetService("MarketplaceService"):PromptPurchase(player, Id)
end)

Help would be much appreciated.

2 answers

Log in to vote
0
Answered by 6 years ago
local Id = 626438744
local Gamepass = game:GetService("GamePassService")
local 
game.Players.PlayerAdded:connect(function(plr)

    if Gamepass:PlayerHasPass(player, Id) then
        game.LOCATIONOFTOOL.Toolname:clone().Parent = plr.Backpack
        game.LOCATIONOFTOOL.Toolname:clone().Parent = plr.StarterGear






end)

This code should work.

0
Not working. killerthedemon 14 — 6y
0
oh rip forgot to remove that "Local" sorry AwesomeBuilder346 11 — 6y
Ad
Log in to vote
0
Answered by 6 years ago
local Id = 626438744
local Gamepass = game:GetService("GamePassService")
local tool = game.ServerStorage:WaitForChild("TOOLNAME") --change tool name and make sure its in serverstorage

game.Players.PlayerAdded:connect(function(plr)

    if Gamepass:PlayerHasPass(player, Id) then
        tool:Clone().Parent = plr.Backpack
        tool:Clone().Parent = plr.StarterGear
end)

Answer this question