Make a part of a gui appear when the player owns a game pass.
I’ve tried making it so that a specific part of the GUI is visible when a player owns a gamepass. Ive tried using this script but it wouldn’t work. Please help me out
The local script is something else that has to do with the button itself but the script is the one i need help with!
I assume the second picture is the Gamepass gui. You can remove the script.Gui.Visible = false part of the script and go to the gui instance property and uncheck RestetOnSpwan. Also, do you have your output window open to show you any errors?
Yeah the second picture is of the gamepass button, but im not sure what you meant by script.Gui.Visible = false since I didn’t write that in the script
the problem is you should be doing it in a local script because it is a GUI, but you also want to be checking if the player owns the gamepass from server, so i suggest having a remotefunction, that from the localscript, asks the server if the player owns, and the sever returns true or false (Of course you have to script that)
It would be something like this Server Script
local RemoteFunction = game.ReplicatedStorage.RemoteFunction
local MPS = game:GetService("MarketplaceService")
local gamepass = 123456
RemoteFunction.OnServerInvoke:Connect(function(plr)
local Data = MPS:UserOwnsGamePassAsync(plr.UserId,gamepass)
return Data
end)
And then in your local script you would remove the gamepass check, and include this:
local OwnsGamepass = game.ReplicatedStorage.RemoteFunction:InvokeServer()
if OwnsGamepass == true then
script.Parent.Visible = true
end
There’s no need to check if the player owns the Game Pass on the server, this is just to make a GUI visible. Any actions that the player can take using the GUI will need to be validated anyway.
Sorry, I made a typo in the event name that I didn’t correct in the code I posted. I’ve fixed it now. In the future, check the Output window to see what issues with your scripts are.