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
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)
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.
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)
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.