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
print("owned")
end
end
What I am using to activate the function. It is located inside of a function that is activated when the play button is clicked.
onPlayerAdded()
Thank you for your time!