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

How do I check to see if the player has the given gamepass and give them the item?

Asked by
Avoxea 48
4 years ago
passId = 6632153  --gravity
passId2 = 6632270 --speed
market = game:GetService("MarketplaceService")

game.Players.PlayerAdded:Connect(function(player)
    function hasGravityPass(player)
        return market:UserOwnsGamePassAsync(player,passId)
    end
    function hasSpeedPass(player)
        return market:UserOwnsGamePassAsync(player,passId2)
    end
    player.CharacterAdded:Connect(function(char)
        if hasGravityPass() == true then
            grav = game.ServerStorage.GravityCoil:Clone()
            grav.Parent = player.Backpack
        end
        if hasSpeedPass() == true then
            speed = game.ServerStorage["Acceleration Coil"]:Clone()
            speed.Parent = player.Backpack
        end
    end)
end)

It is returning with an error of "Argument 1 missing or nil"

1 answer

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago
passId = 6632153  --gravity
passId2 = 6632270 --speed
market = game:GetService("MarketplaceService")

game.Players.PlayerAdded:Connect(function(player)
    player.CharacterAdded:Connect(function()
    if market:UserOwnsGamePassAsync(player.UserId,passId) then
    game.ServerStorage.GravityCoil:Clone().Parent = player:WaitForChild("Backpack")
end
if market:UserOwnsGamePassAsync(player.UserId,passId2) then
    game.ServerStorage["Acceleration Coil"]:Clone().Parent = player:WaitForChild("Backpack")
     end
   end)
end)

this will give them the item when the character has loaded if they have the gamepass

0
okay thanks Avoxea 48 — 4y
Ad

Answer this question