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.


01local MarketplaceService = game:GetService('MarketplaceService')
02local ProductId = 12345
03 
04game.Players.PlayerAdded:connect(function (player)
05    if MarketplaceService:PlayerOwnsAsset(player, ProductId) then
06        --create leaderstat
07        local stat = Instance.new('NumberValue')
08        -- parent to default leaderstats folder/container/model
09        stat.Parent = player['path to leaderstats folder']
10 
11    end
12end)
Ad