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

Is it possible to make a gamepass that is given to specific players?

Asked by 3 years ago

Im making a 2x selling gamepass for a simulator im creating and I want to give the gamepass to my friends that helped create it. This is the script im using and i want to know if i could change the script so instead of it being used for players with the gamepass its for specific players or so i can give them the gamepass. btw the gamepass id is on a IntValue attached to the script

game.Players.PlayerAdded:Connect(function(player)

    local marketservice = game:GetService("MarketplaceService")

    local can = true
    repeat wait() until player:FindFirstChild("leaderstats")
    local leader = player:FindFirstChild("leaderstats")
    if leader then
    repeat wait() until leader:FindFirstChild(script:WaitForChild("Currency").Value)
    local currency = leader:FindFirstChild(script:WaitForChild("Currency").Value)
        if currency then
            local folder = Instance.new("Folder",player)
            folder.Name = "2xGamepass"
            local oldmoney = Instance.new("IntValue",folder)
            oldmoney.Name = "OldMoney"
            oldmoney.Value = currency.Value
            local give2x = Instance.new("IntValue",folder)
            give2x.Name = "Give2x"
            give2x.Value = 0

            currency.Changed:Connect(function()
                if marketservice:UserOwnsGamePassAsync(player.UserId, script:WaitForChild("GamepassId").Value) then


                if can == true then
                    can = false
                if currency.Value > oldmoney.Value then
                give2x.Value = currency.Value - oldmoney.Value

                currency.Value = currency.Value + give2x.Value

                oldmoney.Value = currency.Value
                    can = true
                    else

                            oldmoney.Value = currency.Value
                            can = true


                end

                end
                else
                    oldmoney.Value = currency.Value
                end
            end)

        end
    end
end)

1 answer

Log in to vote
0
Answered by
moo1210 587 Moderation Voter
3 years ago

Add an override with an UserId (or you could use usernames but then if they changed there username they will lose it) if marketservice:UserOwnsGamePassAsync(player.UserId, script:WaitForChild("GamepassId").Value) then replaced with if marketservice:UserOwnsGamePassAsync(player.UserId, script:WaitForChild("GamepassId").Value) or player.UserId == freeplayerid then

Ad

Answer this question