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

How do I make it so when the player buys the gamepass it checks it and gives them the gear?

Asked by
bailley5 114
4 years ago
Edited 4 years ago

game.Players.PlayerAdded:connect(function(player) while true do if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.userId, 7384369) then if player.Backpack:FindFirstChild("GravityCoil") == nil and player.Character:FindFirstChild("GravityCoil") == nil then print(player.Name .. " got an item!") local b = game.Lighting:FindFirstChild("GravityCoil"):Clone() b.Parent = player.Backpack end end wait(1)
end end)

2 answers

Log in to vote
0
Answered by
0_2k 496 Moderation Voter
4 years ago
Edited 4 years ago
local MS = game:GetService("MarketplaceService")

game.Players.PlayerAdded:Connect(function(plr)
    repeat wait() until plr.Character
    if MS:UserOwnsGamePassAsync(plr.UserId, 7384369) then
        if plr.Backpack:FindFirstChild("GravityCoil") == nil and plr.Character:FindFirstChild("GravityCoil") == nil then
            print(plr.Name .. " got an item!")
            local b = game.Lighting:FindFirstChild("GravityCoil"):Clone()
            b.Parent = plr.Backpack
        end
    end
end)
Ad
Log in to vote
0
Answered by
bailley5 114
4 years ago

~~~~~~~~~~~~~~~~~

~~~~~~~~~~~~~~~~~game.Players.PlayerAdded:connect(function(player) while true do if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.userId, 7384369) then if player.Backpack:FindFirstChild("GravityCoil") == nil and player.Character:FindFirstChild("GravityCoil") == nil then print(player.Name .. " got an item!") local b = game.Lighting:FindFirstChild("GravityCoil"):Clone() b.Parent = player.Backpack end end wait(1)
end end)

0
Defining the players UserId is important, so for this to work mainly you need (player.UserId) not player.userid. Also, no need for the while true do loop. It runs upon them joining the game. 0_2k 496 — 4y

Answer this question