I'm stumped... Any help with getting this to work?

Ok so I’m trying to make it so when you have purchased a gamepass a TextButton becomes visible. Now I’ve gotten it to work but here’s where I need help.

The script I have works when I use it when not in a group game (so a game made on a roblox account)

But as you can assume it doesn’t work for group games for some reason.

I own the gamepass I’m using to test it and it is set correctly but it just won’t work.

Script:

local GamepassId = 51455122 

local frameToShow = script.Parent 

local player = game.Players.LocalPlayer
repeat wait() until player.Character 

local PlayerGui = player:WaitForChild("PlayerGui"):WaitForChild("ScreenGui")

local MarketplaceService = game:GetService("MarketplaceService")
if MarketplaceService:UserOwnsGamePassAsync(player.UserId, GamepassId) then
	frameToShow.Visible = true
end

So this script is in a Local Script in the TextButton that is the textbutton that is supposed to show but doesn’t.

1 Like

Try something like this:

game.Players.PlayerAdded:Connect(function()
 if MarketplaceService:UserOwnsGamePassAsync(player.UserId, GamepassId) then
	frameToShow.Visible = true
 end
end
1 Like

Sorry it didn’t work. It just returned with a few errors

Im not very good at scripting but i think it has to do something with developer products

please let me know if am wrong

local plr = game.Players.LocalPlayer
local mps = game:GetService("MarketplaceService")
local frameToShow = script.Parent

if mps:UserOwnsGamePassAsync(plr.UserId, 17921189) then
	frameToShow.Visible = true
else
	frameToShow.Visible = false
end

I have tried this, and it works.

If this isn’t what you are talking about, try enabling third part sales in your game settings.

2 Likes

Haven’t tried your script yet but yes I have already enabled Thirdparty sales.

It works! Thanks for the help man

1 Like
local Game = game
local Script = script
local Players = Game:GetService("Players")
local Player = Players.LocalPlayer
local MarketplaceService = Game:GetService("MarketplaceService")

local Frame = Script.Parent
local GamePassId = 17921189

local Success, Result = pcall(function() return MarketplaceService:UserOwnsGamePassAsync(Player.UserId, GamePassId) end)
Frame.Visible = Result