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

How do get if a player owns a gamepass / prompt game pass from a localscript?

Asked by 6 years ago
Edited 6 years ago

The ID is 1405452320 and I've already tried this:

--> Local Script
script.Parent.Changed:connect(function()
    if not isVis and script.Parent.Visible then
        isVis = true
        if script.Parent.remote:InvokeServer() then
            if enabled.Value then
                sf("Info")
                page = 0
            else
                sf("Disabled")
            end
            script.Parent.PageNum.Text = "---"
        else
            --script.Parent.Disabled.Visible = true
            --/\ remove that comment when ready
            script.Parent.remote:InvokeServer(true)
        end
    elseif not script.Parent.Visible then
        isVis = false
    end
end)
--> Script (under same parent as localscript, and remote is a RemoteFunction)
script.Parent.remote.OnServerInvoke = (function(p,purchase)
    if purchase then
        game.MarketplaceService:PromptGamePassPurchase(p,1405452320)
    else
        return game.GamePassService:PlayerHasPass(p,1405452320)
    end
end)

Filtering is not enabled, so despite my bad practice, it should still work.

1 answer

Log in to vote
0
Answered by
RjsMc 48
6 years ago
Edited 6 years ago

Instead Try doing this:

Note: Player is game.Player.LocalPlayer

local owns = game:GetService("MarketplaceService"):PlayerOwnsAsset(player, 1405452320)
                if owns == true then -- If player owns gamepass
--Action
else -- If player does not own gamepass
-- Action
end

Also note, this wont work in studio. You actually have to play it in your real game. PlayerOwnsAsset is something you can use. If this worked please mark as answered.

Ad

Answer this question