How to make reserved server accessable to friends only?

My game relies on places so VIP servers won’t work, the only way I can think of to make a private server system is to use reserved servers.

The problem I’m having right now is making friends access the reserved server of the owner only. I tried using datastores but it seems to not work.

I have been trying to do this for 2 days but I still can’t find a solution. Any scripts or help would be really appreciated!

1 Like

You can try:

game.Players.PlayerAdded:Connect(function(plr)
    if not plr:IsFriendsWith(OwnerId) then
        plr:Kick("You don't have permission to join this server!")
    end
end)

Replace the OwnerId with the reserved server owner’s ID. This script will basically checks if the player joined is friended with the server owner.

Edit: Thanks to @Forummer for reminding me. Changed .IsFriendsWith() to :IsFriendsWith().

2 Likes

https://developer.roblox.com/en-us/api-reference/function/Player/IsFriendsWith

Methods use the colon operator.

if LocalPlayer:IsFriendsWith(Player) then

3 Likes

I have developed two modules that can do this, I will keep them private, but I can explain the methods I used.

So from what i undestand, what you are trying to archive is letting peoples (user friends) join a reserved server when it has already been created.

The first method you could use would be with the datastore service , you could store the player id or a short randomly generated code that contains the reserved server code. With this code you could then teleport the user in the reserved server.

Another method would be to use Cross-Server Messaging, you could send a request with the id of the player or a pre-defined random string and then wait if another server responds positively by returning this code. Note however that to use this method you must first communicate the code to the new reserved server itself because you can not access it in it.

If you want to make it friend only or add a option to set the server friend only then you could use @Forummer and @Maytidis_good answer to verify if the user is friend with the owner before teleporting him in the reserved server.

5 Likes