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

How would I find if a player has a gamepass?[SOLVED]

Asked by 4 years ago
Edited 4 years ago

The title explains it, I've tried to get somewhere but it doesn't appear to work, I'm making a basic little game where you click and it gives you points, blah blah blah, and for my effort of trying to make some profit I'm adding a gamepass which would increase your profits but I need help finding if a player has said gamepass. This isn't the entire script, but instead just the parts that relate to the gamepass and its function.

local UserId = game.Players.LocalPlayer.UserId

player.leaderstats[currencyName].Value = player.leaderstats[currencyName].Value + 1
if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(UserId, 8434678) then
    player.leaderstats[currencyName].Value = player.leaderstats[currencyName].Value + 4
end

This is a normal script so I'm aware as to the fact that calling game.Players.LocalPlayer shouldn't work therefore I need some clearance as to how I should get the UserId.

(If it helps this game only runs servers with one player)

0
game.Players.PlayerAdded:Connect(function(player) local userId = player.UserId end killerbrenden 1537 — 4y
0
Thanks but I ended up fixing it myself ^ jackfrcsty 15 — 4y
0
Alright, no problem! killerbrenden 1537 — 4y
0
Put [SOLVED] in your title so other people know it's been solved. killerbrenden 1537 — 4y

Answer this question