I am making a custom private server system, and I was wondering if the player chose to let other people into his reserved server (TeleportService:ReserveServer()), and I was planning to script that by giving a code to the player he can give to his friends, is it ok if I use the reserved server Id acting as a code, or is that not okay?
Well, if you’re talking about letting other players (Friends) being able to head inside the ReservedServer
it’s possible
You just need to save an Array (Or table) of Players to determine who’s joining and who won’t, then after the “Host” invites everyone, that specific amount of Players would be teleported to that Private Server
Thing with that, is it’d just be the same code which players would easily guess if that was the case so not really
You could implement specific conditional checks though (Changing the code to something else would be fine)
--Server-Sided Script
local TPService = game:GetService("TeleportService")
local TPCode = TPService:ReserveServer(game.PlaceId)
local function TeleportPlayers(HostCode)
local InvitedPlayers = {}
for _, Player in pairs(game.Players:GetPlayers()) do
if Player.Code.Value == HostCode then --We'd be inserting a StringValue into a Player Object, and we're passing a "HostCode" to check if the player is inside this private server to add them
table.insert(InvitedPlayers, Player)
end
end
TPService:TeleportToPrivateServer(game.PlaceId, TPCode, InvitedPlayers)
end
What’s wrong with ROBLOX’s private server system?
Not exactly what I mean, i mean what if i wanted the player to be able to give another random player the reserved server code, so they can type it in a textbox and join. Is it ok to be giving the player the server id?
when i used that, it doesnt work for universes
I’m not sure if I follow, but if you’re only just “showing” them the Server ID then there’s nothing wrong with that
They’re just a random player that you wanted to give the Code
to so they can join it
Thats what I wanted to know I didnt know if it was bad or anything to give the server id
Also I know this is off topic but. I got a http 403 for making a reserveserver(), i searched this up and someone said you have to do a pcall, do you think you can help me with this?
Do you have “Enable Third Party Teleports” on? That could possibly be why
Everything is on, yeah. All the settings. (and i do not know how to use pcall)
local success, errorMessage = pcall(function()
id = TeleportService:ReserveServer(game.PlaceId)
end)
if success then
-- do stuff
is this correct? (even if this was correct if it failed it still wouldnt work right, so i dont know why it is doing this)
It should work? Unless if you’re requesting something using HTTPService
, which could result in that error
I believe it’s just due to how your code is made, if you haven’t followed the right parameters & functions TeleportService
give you, it’d result in that HTTP 403 error
The thing is I used the same thing in another script and it worked, is it because I am putting it in a variable? (i have to put it in the variable to get the id of the server unless another way)
You’re probably referencing the id
wrong, cause I see the script you’re using if possible?
Hold on, I am going to try one more thing: Storing it into 2 variables since I just found out it returns 2 values not one.
My other reply wasnt the solution, here is the code.
game.ReplicatedStorage.BuyServerEvent.OnServerEvent:Connect(function(player, serverName, serverType)
local Data = ProfileData:Get(player)
if Data.Server == nil and string.len(serverName) < 25 then
MarketPlaceService:PromptProductPurchase(player, 1173004232)
MarketPlaceService.PromptProductPurchaseFinished:Connect(function(plr, assetId, isPurchased)
if isPurchased then
if assetId == 1173004232 then
local function removespaces(str)
return str:gsub(" ","")
end
local access_code, private_server_id
local type = removespaces(serverType)
local success, errorMessage = pcall(function()
print(game.PlaceId)
access_code, private_server_id = TeleportService:ReserveServer(game.PlaceId)
end)
if success then
print("Success!")
Data.Server = {
ServerName = serverName,
ServerOwner = player.Name,
Id = access_code,
ServerCode = access_code,
PrivateServerType = serverType,
}
print(Data.Server)
end
end
end
end)
end
end)
I’m assuming this could be why…? You never exactly specified a second argument for the private_server_id
variable, which could still be resulted as nil
(Or non-existent)
How do I fix that? What other argument do I use? (also I tried just doing access_code and removing privateserverid and that did not work either.)
I mean you could just remove the parameter, since the private_server_id
can be “read only”
Try that and see if anything changes?
local access_code
local stype = removespaces(serverType)
local success, errorMessage = pcall(function()
print(game.PlaceId)
access_code = TeleportService:ReserveServer(game.PlaceId)
end)
if success then
print("Success!")
so this? also are you sure im not making the function incorrectly (like where “if success then” is supposed to go and stuff.