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

How would i make this script work only if i own a certain gamepass?

Asked by 4 years ago
local Pants = script.Pants
local Shirt = script.Shirt



script.Parent.ClickDetector.MouseClick:connect(function(Player)

    local Character = Player.Character
    if Character == nil then return end

    -- Get new pants
    local CharacterPants = Character:findFirstChild("Pants")
    if CharacterPants then CharacterPants:Destroy() end
    Pants:Clone().Parent = Character

    -- Get new pants
    local CharacterShirt = Character:findFirstChild("Shirt")
    if CharacterShirt then CharacterShirt:Destroy() end
    Shirt:Clone().Parent = Character
end)

How would i make this script work only if i own a certain game pass?

2 answers

Log in to vote
0
Answered by
AizakkuZ 226 Moderation Voter
4 years ago

https://developer.roblox.com/en-us/articles/Game-Passes-One-Time-Purchases This article will tell you how to use GamePasses in your game for monetization, make sure to thoroughly read it.

For things like items you can purchase over and over go here, https://developer.roblox.com/articles/Developer-Products-In-Game-Purchases again make sure to thoroughly read it.

0
Doesn't help... itadakimasu_Kurepu 29 — 4y
0
Yes it does.. AizakkuZ 226 — 4y
0
Anyways this might not help him, he will be need MarketPlaceServer instead. Since he already has the gamepass (I assume).) XviperIink 428 — 4y
Ad
Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

For this, you will be needing MarketPlaceService:UserOwnsGamePassAsync(). You can learn more about it here

local Pants = script.Pants
local Shirt = script.Shirt

local MarketPlaceService = game:GetService("MarketplaceService")

script.Parent.ClickDetector.MouseClick:connect(function(Player)

    if MarketPlaceService:UserOwnsGamePassAsync(Player.UserId, 0) and Player.Character ~= nil then -- Change "0" to the gamepass id
        local Character = Player.Character

        -- Get new pants
        local CharacterPants = Character:findFirstChild("Pants")
        if CharacterPants then CharacterPants:Destroy() end
        Pants:Clone().Parent = Character

        -- Get new pants
        local CharacterShirt = Character:findFirstChild("Shirt")
        if CharacterShirt then CharacterShirt:Destroy() end
        Shirt:Clone().Parent = Character
    end
end)

If this helped, remember to accept else report the error and I will fix it asap!

Answer this question