How to make a GUI that can be accessed by a player who owns a asset, shirt, game pass etc., this is the script i used on the gamepass
1 | GamepassID = 4636698 |
2 | game.Players.PlayerAdded:connect( function (plr) |
3 | if game:GetService( "GamePassService" ):PlayerHasPass(plr,GamepassID) then |
4 | game.StarterGui.Shop.Frame.Visible = true |
5 | end |
6 | end ) |
Please help
1 | game.Players.PlayerAdded:Connect( function (plr) |
2 | if game:GetService( "MarketplaceService" ):PlayerOwnsAsset(plr.userId,<asset id>) then |
3 | plr.PlayerGui.ScreenGui.Enabled = true |
4 | else |
5 | plr.PlayerGui.ScreenGui.Enabled = false |
6 | end |
7 | end ) |
basically that.
First, you should put this inside the gui. Make a LocalScript right inside it so script.Parent is the Frame, like this https://gyazo.com/4792fdcbc016f043c87cb607cc02a56a.
Here's the code you should insert:
1 | local player = game.Players.LocalPlayer |
2 | local GamepassID = 4636698 |
3 | local marketplaceService = game:GetService( 'MarketplaceService' ) |
4 |
5 | if marketplaceService:UserOwnsGamePassAsync(player.UserId, GamepassID) then |
6 | script.Parent.Visible = true |
7 | else |
8 | script.Parent.Visible = false |
9 | end |
This checks if the player has the gamepass using MarketplaceService, then sets it visible or invisible. The players gui is also in PlayerGui, but it's better to use a LocalScript inside the GUI.