How i can make label 0/25 players at server (place)

Yeah but I think they are going to have multiple servers so if the servers are handled on the server then the client will always get the correct amount of players also if they want the players to be teleported then it will have to be done on the server. You could use PlayerAdded but then you also need to know which server a player joins, this is of course if they’re using multiple servers which I’m unsure about.

Where do I specify the Id of the place where the player will go?

If you want player count of a vip server then store the vip server code, and player count in datastore.

You would define that in a server script. In the example I gave you I haven’t done that since it was made clear but when your ready to teleport player you would loop through the Servers table and teleport them. I believe you can send a table of players so you could just send the Servers Table instead of looping through. I would look into teleport service to see how it works.


Did I do everything right here or do I need something else?

local function GetPlayerCount(server : string) : number
     local amount = #Servers[Server]
     return amount
end

Of course, this is the basic version and you do need to add to it but in theory, it should work. Like @Synitx said instead of looping through the entire table you could get the length of the table instead. Not sure exactly why I did it that way but do be sure to change that.

You could also remove the function completely and just change Event arguments like this: RemoteEvent:FireAllClients(server, #Servers[server])

Well, what is there now that I have done everything, the system should work?

I don’t really understand this system could you make the player teleport just before I just did the GUi and the teleport button and now I don’t know how to do something here

As long as you have defined all the paths and everything it should work. This is only for changing the number so this won’t actually teleport anyone.

Unfortunately, I can’t just give you an entire script but what I would do is when the Server is ready to send players whether that is a timer or when the server is full. You would get all the players currently in the server and use TeleportService to send the players to your desired place

image
As far as I understand you, should I write in an empty line so that the player is teleported? this is a local script

You shouldn’t handle teleporting in a client script. You should just add it into the server script.

I’m not really fimilar with teleport since I haven’t used it but looking through the Developer Hub on TeleportService it looks fairly straightforward.

local TeleportService = game:GetService("TeleportService")

local PlaceID = -- Enter ID here

-- When your ready to teleport
TeleportService:TeleportPartyAsync(PlaceID, {tableOfPlayers})

If this isn’t correct I’m sure someone will help.


I don’t really understand I’m entering the id, but I’m going to do a lot of servers, how could I make them so that the gui appears automatically through the table and if I insert the server code 1, the players will only connect there (

So change the Servers Table to this:

local Servers = {
   ["Server 1"] = {
         ["PlaceID"] = -- Enter Place ID for server 1 Note: Add a comma after each line
         ["Players"] = {}
   }
}
-- Change the TeleportServer:TeleportPartyAsync line to this v
TeleportService:Teleport(Servers[server]["PlaceID"], player)

-- Remote the placeId Variable inside of the remote event
-- and move TeleportService to the top of the script


okey, what i can do?

Let me just update the previous script and then it’s all up to you from there.

-- Server Side (script or modulescript)

local TeleportService = game:GetService("TeleportService")

local RemoteEvent = -- Path to Remote Event

local Servers = { -- Create a table for servers
   ["Server 1"] = {
      ["ID"] = 3432525, -- Place ID change those numbers to yours
      ["Players"] = {},
   }, -- You could change this to a number but you would want to store players in here I'm assuming
}

RemoteEvent.OnServerEvent:Connect(function(player : player, server : string)
   local ChosenServer = Servers[server]  

   -- Add some checks to see if a player exists in case the client is exploiting 
   -- vv basic checks please add more for safety and also a limiter for remotes
   if not ChosenServer  then return end -- Server doesn't exist
   if ChosenServer["Players"][player] then return end -- They are already in server

   table.insert(Servers[server]["Players"], player) -- Adds player to the server table 
   RemoteEvent:FireAllClient(Server, #Servers[server]) -- Update all the clients

   pcall(function() -- Not sure if this is needed but just to be safe
      TeleportService:Teleport(ChosenServer["ID"], player)
   end)
end)

This should be the server script. This should all work in theory but I highly recommend learning what everything does since it will help you debug later if needed.

Try using MessageService

Here’s a good tutorial on how to use it

Hope this helps!

1 Like


Thank you for such an effort, but the button does not work, can something need to be changed in the local script?