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

How to make gamepass tools exist in player's inventory forever?

Asked by 6 years ago

This is the code I use for gamepass tools.

local id = 0000000 --Change this to the gamepass id you want

game.Players.PlayerAdded:connect(function(player)
    if Game:GetService("GamePassService"):PlayerHasPass(player, id) then --Added the Parameters 
    local clone =  game.ServerStorage.VoidSword:Clone() -- You need the parenthesis and to determine where it will be parented to
    clone.Parent = player:WaitForChild("Backpack") --In this game the player's Backpack
        print(player.Name .. " has the game pass!")
    else
        print(player.Name .. " doesn't have the game pass...")
    end
end)

But when the player dies after receiving the tool, it doesn't appear in the player's backpack again. (Credit to yougottols1 for helping me with the script)

1 answer

Log in to vote
0
Answered by
CootKitty 311 Moderation Voter
6 years ago
Edited 6 years ago

Just add a CharacterAdded event to the joining players so that the tool gets added every time they respawn if they have the tool.

local id = 0000000 --Change this to the gamepass id you want

game.Players.PlayerAdded:connect(function(player)
    if game:GetService("GamePassService"):PlayerHasPass(player, id) then
        player.CharacterAdded:Connect(function() -- added character added event
            local clone =  game.ServerStorage.VoidSword:Clone()
            clone.Parent = player:WaitForChild("Backpack")
        end)
    end
end)
Removed comments you left from copying this code from the wiki
1
Thanks! bomblitz06 94 — 6y
Ad

Answer this question