Make a part of a gui appear when the player owns a game pass

image
image

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?

You could add another event which executes when the player has bought the gamepass in game.

Also a while loop isn’t wise, since you want to aim on reserving resources.

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

Hmm i see what you mean, is it okay if i try to use this script and see if it works?

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

Tried this script but it didn’t work!

did you create a remotefunction in serverstorage?

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.

Of course, go ahead and try to get it working!

Wait i messd up i meant to respond to anoyher player

So ive tried but cant get it to work

same script as u sent me but it dosent work!

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.

Oh i see im going to test the script now if thats okay?

[quote=“Maastrophy, post:15, topic:956658”]

local getOwnershipSuccess, ownership = pcall(function()
    return marketplaceService:UserOwnsGamePassAsync(player.UserId, gamePass)
end)

if getOwnershipSuccess and ownership then
    script.Parent.Visible = true
end

the problem in your code is here, it should be this

local success,errormessage = pcall(function()
     maketplaceService:UserOwnsGamePassAsync(player.UserId, gamePass)
end)
if success then
     script.Parent.Visible = true
end

I though you did?

It would be easier to just go to the gui to uncheck reset on spawn

Thanks for the help but ive found the solution!

Hi thanks for the help but i found the solution!

Looks like it worked, thank you so much! Is it okay if i use that script?

Can i ask what the solution is, im also struggling with similar problem