Players owns gamepass GUI

So i’m working on a gui that shows the player when he owns the gamepass.

But the problem is that it doesn’t work.

my code so far:

local id = 18433189

game.Players.PlayerAdded:Connect(function(player)
if game:GetService(“GamePassService”):PlayerHasPass(player, id) then
script.Parent.Visible = true
else
script.Parent.Visible = false
end
end)

gamepassservice is deprecated and should not be used, use MarketPlaceService:UserOwnsGamePassAsync() instead

GamePassService is deprecated and MarketplaceService:UserOwnsGamePassAsync(player.UserId, id) should be used instead

Also, if this is a server script, script.Parent would be where the script is stored, which most likely isn’t the gui itself. Even then, exploiters can just enable the gui themselves.

I recommend a system where it checks if you own the gamepass, and if you do, it clones the gui from a secure place such as ServerStorage and places it in the player’s playergui. Of course, this would be a regular/server script inside of ServerScriptService, not a local script

1 Like

I think the issue is that PlayerHasPass is officially deprecated and cannot work anymore, the Service itself though can be used (But not its custom functions)

You can use MarketplaceService’s UserOwnsGamePassAsync function (Which is the more latter & modern service) instead to reference the Gamepass Check that way

Also uhh, if this is on a Server Script the changes will not be made across the client-side so why not just reference this entirely on a LocalScript? You can use the LocalPlayer & get their Id from there

local id = 18433189
local Player = game.Players.LocalPlayer

if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(Player.UserId, id) then
    script.Parent.Visible = true
else
    script.Parent.Visible = false
end

Of course if you want it to secure it, you can use some kind of system server-sided as @EmbatTheHybrid mentioned, but I just did it for the sake of the OP’s concern

1 Like

Or better yet, no need for an if statement like that, just have the condition set the visible property since it returns a boolean

script.Parent.Visible = game:GetService("MarketplaceService"):UserOwnsGamePassAsync(Player.UserId, id)
1 Like

thanks for the help :slight_smile: and everyone else