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

Open Frame If Player Owns Pass?

Asked by
Rynappel 212 Moderation Voter
4 years ago

I have a textbutton and you click it and its supposed to open a frame ONLY if you have a gamepass, but it doesnt work? Why not though..

local frame = script.Parent.Parent.Parent.TeleportFrame
local player = game.Players.LocalPlayer
local id = 7617401

script.Parent.MouseButton1Click:Connect(function()
    if game:GetService("MarketplaceService"):PlayerOwnsAsset(player, id) then
        frame.Visible = not frame.Visible
    else
        game:GetService("MarketplaceService"):PromptGamePassPurchase(player, id)
    end
end)
2
Use PlayerOwnsGamePassAsync. namespace25 594 — 4y

2 answers

Log in to vote
1
Answered by 4 years ago
Edited 4 years ago

You should be using this function https://developer.roblox.com/en-us/api-reference/function/GamePassService/PlayerHasPass

The DevHub for PlayerOwnsAsset strictly says not to use it with GamePasses.

Ad
Log in to vote
1
Answered by
raid6n 2196 Moderation Voter Community Moderator
4 years ago
Edited 4 years ago

use UserOwnsGamePassAsync


script.Parent.MouseButton1Click:Connect(function() local id = YOUR_ID_HERE game:GetService("MarketplaceService").PromptGamePassPurchaseFinished:Connect(function(plr,ido,purchased) if purchased and ido == id then script.Parent.Parent.Parent.TeleportFrame.Visible = true end end) game.Players.PlayerAdded:Connect(function(plr) plr.CharacterAdded:connect(function(char) if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(game.Players[char.Name].UserId, id) then script.Parent.Parent.Parent.TeleportFrame.Visible = true end end) end)

Answer this question