Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Having gamepass trouble?

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?

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.