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

Why I Can't give Perks to Players with Game Pass?

I don't even get any error

local player = game.Players.LocalPlayer
local market = game:GetService("MarketplaceService")
game.Players.PlayerAdded:Connect(function(player)
	if market:UserOwnsGamePassAsync(player.UserId, 9174386) then
		print("Owns the game pass")
	end
end)

1 answer

✓ Accepted answer

Hello.

Problem

You used LocalPlayer in a ServerScript. ServerScript's run on a physical server instead of a client, so LocalPlayer will always return nil/nothing.

Solution

Remove the player variable on the main scope. There is no need for the variable as the player is automatically obtained using the PlayerAdded parameter.

Fixed Code:

local market = game:GetService("MarketplaceService")

game.Players.PlayerAdded:Connect(function(player)
    if market:UserOwnsGamePassAsync(player.UserId, 9174386) then
        print("Owns the game pass")
    end
end)

This discussion is preserved as it was. New answers, comments, and votes are closed.