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?
✓ ANSWER ACCEPTED
Having gamepass trouble?
1 answer
✓ Accepted answer
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)
This discussion is preserved as it was. New answers, comments, and votes are closed.
