Radio Gamepass Gui

In my game, players can buy a radio gamepass and it has a GUI that appears on the side of the player’s screen. I would like this GUI to be invisible when the main menu is opened, and when they click play, (to close the main menu) the radio GUI becomes visible. To do this, I created a function that checks to see if the player owns the gamepass, and call on the function when the play button is clicked. I get an error, however, which says that UserId is nil. It seemed to work when I didn’t refer to the function later on in the script. Maybe I am doing something wrong??

The function I made to check if the player owns the gamepass and toggle the GUI visible:

function onPlayerAdded(player)
if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId, 10098696) then
	player.PlayerGui.Radio.Frame.Visible = true

What I am using to activate the function. It is located inside of a function that is activated when the play button is clicked.


Thank you for your time!

1 Like

it is easy to make but u maked it good gg my dude

1 Like

I don’t know if you read all of the top part, but I get an error for UserId, saying it is nil.

i maked an script u can copy if u want put the next thing in serverScriptService like a script

local function WaitForChild(parent, childName)

assert(parent, “ERROR: WaitForChild: parent is nil”)

while not parent:FindFirstChild(childName) do parent.ChildAdded:wait() end

return parent[childName]



local GamePassService = game:GetService(‘MarketplaceService’)

local PlayersService = game:GetService(‘Players’)

local GamePassIdObject = script:WaitForChild(‘GamePassId’)


if player.Character.Name == “EverettDBXZ” or GamePassService:UserOwnsGamePassAsync(player.userId, GamePassIdObject.Value) then


end end)


now in replicated storage add a moduleScript then put this

return function(player)
local function weldBetween(a, b)
local weld =“ManualWeld”)
weld.Part0 = a
weld.Part1 = b
weld.C0 =
weld.C1 = b.CFrame:inverse() * a.CFrame
weld.Parent = a
return weld;
local char = player.Character
local hand = game:GetService(“ServerStorage”):WaitForChild(“Radio”):clone()
weldBetween(char:WaitForChild(“Torso”), hand)

and in the script of serverScriptService add an IntValue named “GamePassId” then the value of it will be the gamepass :smiley:

I already have a working radio, my issue is that I want to have my radio’s GUI become visible once the play button is pressed so it isn’t visible in the main menu. However, when I refer to my function I pasted above, it gives me an error saying that player.UserId doesn’t exist.

What’s wrong with this?

local MarketplaceService = game:GetService("MarketplaceService")

if MarketplaceService:UserOwnsGamepassAsync(player.UserId, 10098696) then
	player.PlayerGui.Radio.Frame.Visible = true

player is located as game.Players.LocalPlayer, but shouldn’t it be a parameter of the function? I don’t want it to be when a player joins.

You can make it so once the player clicks play it fires a remote event that checks if the player has the gamepass like this
Local script(Inside of the button):

-- your code
game.ReplicatedStorage.CheckForRadioPass:FireServer()  -- or whatever you will name the remoteevent

Script Inside of ServerScriptService:

if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId, 10098696) then
	player.PlayerGui.Radio.Frame.Visible = true

and of course you will have a remote event in ReplicatedStorage called CheckForRadioPass or whatever u will name it but remeber to change the name of the remote event in the script if you will change the name Hope i helped .:smile:

I noticed the issue.

Are you putting the player?
If it was a client script then you should have put onPlayerAdded(game.Players.LocalPlayer)
If you didn’t, then that is why it is giving an error, because the player doesn’t exist.

I tried both of these and they both work, however I tested when a player respawns and the GUI doesn’t reappear. I bet it’s the radio’s fault, so I will look into that. Thanks for the help!

When The player Respawns does the Play Button reappear?

If not then try to set ResetOnSpawn off in the properties of the gui

I completely forgot it’s a separate GUI from my current GUI, I will have to look. I am pretty sure it may clone the GUI into PlayerGui, so I have no clue. You are probably right.

1 Like

So what you mean is that it clones it into the playerGui

yeah, it is stored in replicatedstorage/serverstorage or something.

it’s a free model radio, lol.

if that is the case then
make it so when it clones it it does GuiExample.ResetOnSpawn = false

But Do that if the main menu doesn’t reappear