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

Having gamepass trouble? [closed]

Asked by 9 years ago

I want to make it so if a player has a gamepass, they'll get one gem (Called 'Gems' in leaderstats) every time they enter the game. How do you do this?

Closed as Not Constructive by evaera

This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.

Why was this question closed?

1 answer

Log in to vote
0
Answered by
ImageLabel 1541 Moderation Voter
9 years ago

Checking for ownership

PlayerOwnsAsset, when used in LocalScripts, will return live results from the ROBLOX website. Therefore, no matter when he purchases the item, it will return the most recently updated value.


local MarketplaceService = game:GetService('MarketplaceService')
local ProductId = 12345

game.Players.PlayerAdded:connect(function (player)
    if MarketplaceService:PlayerOwnsAsset(player, ProductId) then
        --create leaderstat
        local stat = Instance.new('NumberValue')
        -- parent to default leaderstats folder/container/model
        stat.Parent = player['path to leaderstats folder']

    end
end)
Ad