PlayerGui Help Required!

So I made this forum talking how to make a gamepass item not being available to everyone’s shop but only the person who bought the gamepass will be able to access the gamepass item in their shop.

And a guy (thanks for him!) commented that I should use playergui to fix my problem. Even though I said that I know what to do now, in reality, I have a small brain and do not how to use player gui, nor how to fix the problem. Can somebody please explain how to access playergui to fix my problem rn, thank you!

Here’s a piece of script that might be useful (the gamepass handler):

The variable rainbow is to clone the sword and put it in the items folder for people to see the sword in the shop, rainbow handle variable is to make the people see the item’s model in the shop.

You put hasPass = MPS:UserOwnsGamePassAsync(player.UserId, RainbowId) but there is not player variable, unless I can’t see the full script from this image

there is a player parameter in the player added function

Oh, I didn’t see that. My bad, in order to get PlayerGui, you must use a :WaitForChild() connector. For example:

local PlayerGui = player:WaitForChild("PlayerGui")
local shopGui = --wherever your shop GUI is located
shopGui.Parent = PlayerGui

ah ok, so for my situation I want the gamepass items to appear in the shop only for the player, so do I have to make the shopgui.Parent to PlayerGui then insert the gamepass item to the shop? How? (reminder: I’m kind of a new scripter so I need more explanation sorry about that!)

Where did you even use PlayerGui?

I just got a response in my previous forum which said i should use playergui, I just don’t know how to use it for my script that’s all.

Inside the shopGui you could put a image button or something that when clicked it prompts the gamepass

Hello, So are you trying to duplicate/insert a gui into the playergui is that what is going on?

I been trying to make a gamepass which grants a sword inside the shop, the problem I’m having is that when somebody has the gamepass, the items appears in everyone’s shop, I made a forum about this and somebody suggested playergui. Everyone is trying to help me out rn and i really appreaciate that, but I am still confused on what to do, if you need any pictures feel free to ask me!

This must mean in your script you have made this gui appear for everyone with most likely a server script.
When you have your If haspass == true then after that you can do

yourgui.Parent = player:FindFirstChild("PlayerGui")
this will insert the gui into the player’s own startergui ‘playergui’.
Note, that will only work if the gui is an entire screengui
otherwise:

IF you want to attach a frame or a picture or a button (whatever) to an already existing screengui for example if the player already has a shop gui you need to get that from the playergui and then parent the guiobject of your choice to THAT shop gui.
Example

--here you need to define what gui you want it in
--shopgui is the gui that already exists
local Shopgui = player:FindFirstChild("PlayerGui"):FindFirstChild("YourGui") --replace the yourgui with the name of your gui
local GamepassItem -- what ever gui you want in the 'shopgui', you can define this since I don't know what it is , but you do
GamepassItem.Parent = Shopgui
--put :Clone after the gamepass item when you have defined it if you need to do so

Many people recommend using local scripts for all gui , but If this works then there should not be a worry

Thanks for this, I’m going to try this code rn and tell you if this work :D, but in the meantime, ima make your saying the solution

Thanks for this, I’m going to try this code rn and tell you if this work :D,

Feel free to ask for more help if a problem occurs