How to Make VIP door but also allow vip player's friends to go in?

I was trying to make a simple VIP wall that will allow players with VIP gamepass but i also wanted to allow the players with the VIP gamepass to be able to also allow their friends to enter the VIP wall with or without the need of buying the same gamepass again. is this possible?

I’ve tried to look for the solution but nothing comes up. Please help

Im not sure if this could be easily achieved.

A way I have come up with would be to store all owners of the VIP gamepass in a datastore (as a table), then whenever a different player, search through the table for all of their friends (friends can be optained through game.Players:GetFriendsAsync(plr.UserId)

1 Like

Simple, just make the door work locally if the player owns the game pass.

Would be better to just check if the player has a friend in the same server that also has VIP. If so you should let them through the door, otherwise don’t let them through the door.

This is equivalent to doing the same check of if someone has VIP the only difference is you add an or to the conditional where you check if they have a friend and if that friend has VIP.

To better simplify.

if hasVIP(player) or hasFriendWithVIP(player) then
 -- adjust collision group for player
end

Edit: Reason I say do it this way, is if the player doesn’t have a friend in the server that has VIP, then they should purchase VIP.

2 Likes

So, first we need to know if the player has the gamepass, after that we need to check if the player are in game and finally check this player’s friends, so lets do it!

 
local Players = game:GetService("Players")
local MarketplaceService = game:GetService("MarketplaceService")
local PlayerOwnsAsset = MarketplaceService.PlayerOwnsAsset
 
Players.PlayerAdded:Connect(function (player)
	local success, doesPlayerOwnAsset = pcall(PlayerOwnsAsset, MarketplaceService, player, ASSET_ID)
	if doesPlayerOwnAsset then
     local HasGamepassPlrId = player.UserId
  for i,v in pairs(Players:GetPlayers())
    if v:IsFriendWith(HasGamepassPlrId)
  -----Doors Open for this player here, u can activate it from a remote event
   end
	else
		print(player.Name .. " doesn't own " )
	end
end)
1 Like

Omg, thank you so much. I’ll come back to you once I’m able to implement this.

sorry, I couldn’t get it to work. I don’t know it work.

This how my original code looks like in the LocalScript under StarterGui

local MarketplaceService = game:GetService(“MarketplaceService”)
local Player = game.Players.LocalPlayer
local doorPart = game.Workspace.VIPDoor.Door
local gamepassId = ######

if MarketplaceService:UserOwnsGamePassAsync(Player.UserId, gamepassId) then
print(“Player owns pass.”)
doorPart.CanCollide = false
else
print(“Player does not own pass.”)
doorPart.CanCollide = true
end

i tried to add in your code within it and nothing happened. it wont even let me in.

Did it print anything? Like plauer owns pass?

I mean the code that I showed worked, but I don’t know how to implement the check friends part to my existing code.

Pretty sure @caioband code works in script not local

i checked, this code only works for asset and will not work for gamepass.

You can find all of the methods for the Marketplace Service at this link here.
The one you’ll want to use for Game Passes is this one here.

The Developer Hub has all the information you’ll need to use the Roblox API.

1 Like

yep, using UserOwnsGamePassAsync works. it finally recognized that I have the gamepass.