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
01 | local passId = 198893078 -- change this to your game pass ID. |
02 |
03 | function isAuthenticated(player) -- checks to see if the player owns your pass |
04 | return game:GetService( "GamePassService" ):PlayerHasPass(player, passId) |
05 | end |
06 |
07 | game.Players.PlayerAdded:connect( function (plr) |
08 | if isAuthenticated(plr) then |
09 | print (plr.Name .. " has bought the game pass with id " .. passId) |
10 | end |
11 | end ) |
Here you can use this script:
01 | local GamePassID = 197848488 --game pass ID |
02 | local Tools = { 'ShieldSphere' } --Put the tools names here. (Tools must be held in the lighting of your game) |
03 |
04 | local gps = Game:GetService( "GamePassService" ) |
05 |
06 | function 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 |
18 | end |
19 |
20 | Game.Players.PlayerAdded:connect(playerJoined) |
Or will this work?
01 | local passId = 198893078 -- change this to your game pass ID. |
02 |
03 | function isAuthenticated(player) -- checks to see if the player owns your pass |
04 | return game:GetService( "GamePassService" ):PlayerHasPass(player, passId) |
05 | end |
06 |
07 | game.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 |
13 | end ) |