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

How do I give an item to the player who bought a gamepass?

Asked by 10 years ago

I'm making a script for my gamepass, but i'm stuck now! I don't know how to clone something into a players backpack and make it stay there permanently.

What i've got so far

01local passId = 198893078 -- change this to your game pass ID.
02 
03function isAuthenticated(player) -- checks to see if the player owns your pass
04    return game:GetService("GamePassService"):PlayerHasPass(player, passId)
05end
06 
07game.Players.PlayerAdded:connect(function(plr)
08    if isAuthenticated(plr) then
09        print(plr.Name .. " has bought the game pass with id " .. passId)
10    end
11end)

2 answers

Log in to vote
2
Answered by 10 years ago

Here you can use this script:

01local GamePassID = 197848488  --game pass ID
02local Tools = {'ShieldSphere'}    --Put the tools names here. (Tools must be held in the lighting of your game)
03 
04local gps = Game:GetService("GamePassService")
05 
06function playerJoined(newPlayer)
07    if gps:PlayerHasPass(newPlayer,GamePassID) then
08        for i,v in ipairs (Game.Lighting:GetChildren()) do
09            for a,c in pairs (Tools) do
10                if v.Name:lower()==c:lower() and v:IsA'Tool' then
11                    repeat wait() until newPlayer:FindFirstChild("Backpack") and newPlayer:FindFirstChild("StarterGear")
12                    v:Clone().Parent = newPlayer.StarterGear
13                    v:Clone().Parent = newPlayer.Backpack
14                end
15            end
16        end
17    end
18end
19 
20Game.Players.PlayerAdded:connect(playerJoined)
0
To support Accept answer or thumbs it up TixyScripter 115 — 10y
Ad
Log in to vote
0
Answered by 10 years ago

Or will this work?

01local passId = 198893078 -- change this to your game pass ID.
02 
03function isAuthenticated(player) -- checks to see if the player owns your pass
04    return game:GetService("GamePassService"):PlayerHasPass(player, passId)
05end
06 
07game.Players.PlayerAdded:connect(function(plr)
08    if isAuthenticated(plr) then
09    local sord = game.ReplicatedStorage.ITEMS.GamepassSword
10        print(plr.Name .. " has bought the game pass with id " .. passId)
11        sord:Clone(plr.Backpack)
12    end
13end)
0
I say use the one I suggested I have tested it and it works fine TixyScripter 115 — 10y

Answer this question