(Solved) How do you show a gui based of whether or not you own a gamepass?

I’ve been trying all day to get a color changing system to work for the shell of the player. but I haven’t been able to figure the first part, how to only show the gui if you own the gamepass for it.
Please help.

We can use MarketplaceService:UserOwnsGamePassAsync(userId: number, gamePassId: number) function to detect whether or not a player owns a gamepass or not. Then we can use that to set the target ScreenGui.Enabled property to if they own the gamepass or not.

  1. Create a script in ReplicatedStorage
  2. Set the RunContext property of that script to Client
  3. Use the MarketplaceService service as shown below

Code:

local MarketplaceService = game:GetService("MarketplaceService")
local Players = game:GetService("Players")

local GAMEPASS_ID = 0 -- put your game pass id here

local player = Players.LocalPlayer
local playerGui = player.PlayerGui
local gamepassGui = playerGui:WaitForChild("GamepassGui") -- name of whatever you called your gamepass only gui

local ownsGamepass = MarketplaceService:UserOwnsGamePassAsync(player.UserId, GAMEPASS_ID)
gamepassGui.Enabled = ownsGamepass

Additional Resources:

1 Like

Thank you so much! Worked perfectly. Before I close this could I ask if you can help me with some code I wrote for the color changing system? It’s not working and I’d like some help on it.

local Players = game:GetService("Players")
local player = Players.LocalPlayer
local Red = game.Players.LocalPlayer:WaitForChild("ShellColor").r.Value
local Green = game.Players.LocalPlayer:WaitForChild("ShellColor").g.Value
local Blue = game.Players.LocalPlayer:WaitForChild("ShellColor").b.Value
local ShellOuter = player.Character:WaitForChild("ShellOuter")
local ShellInner = player.Character:WaitForChild("ShellOuter")
local MarketplaceService = game:GetService("MarketplaceService")


local GAMEPASS_ID = 848500558


local ownsGamepass = MarketplaceService:UserOwnsGamePassAsync(player.UserId, GAMEPASS_ID)
if ownsGamepass == true then
	ShellInner = Color3.fromRGB(Red, Green, Blue)
	ShellOuter = Color3.fromRGB(Red, Green, Blue)
end

Thanks in advance!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.