Hello, I’m just pretty much looking for suggestions on how to get the number of players in a reserved server, and return it to another server, I’ve tried messaging service, but It hasn’t really worked out for me, as I need a constant amount of players as a value.
What is the best way to get the number of players...in a reserved server?
My best bet is to use the Messaging Service. Could you tell my why it doesn’t really work for you?
I’m thinking you can use :PublishAsync() every time someone joins and leaves the reserved server. You can also run it on a loop if you need to constantly check the players in the reserved server.
Well, it hasn’t really been working for me because my game has one big datastore that holds a list of all the reserved servers created, there is a gui in every player that updates every time they click refresh with new values, and since the event would fire every time a player leaves and joins, it wouldn’t give a constant rate of information on the server’s amount of players.
When you get the value from the reserved server you can store that into an IntValue in ReplicatedStorage. From there, whenever a player refreshes their gui, it grabs the value from the IntValue in ReplicatedStorage.
I don’t really see what the problem is.
Why can’t you just do
local PlayersList = game.Players:GetChildren()
I don’t think you understand the post correctly, I know how to count the players in the server and connect it to an event, but I need a way to send the number of players in a reserved server to all the other servers so that they can take it to the client’s gui.
If that’s the case, I suggest you use MessagingService
Yes, I’m currently trying to use the way @moosethepooh said above and see if it solves my problem.
Ok, after some time I’ve finished incorporating that into my system, but it send the amount of players as a JSON encoded value table, and when I try to decode it I get that It can’t apply the value
here is what the error looks like
Are you using a callback function?
Yes, I am using a function that receives the message as the first and only parameter
Here’s a community tutorial I found on the DevForum, maybe run through this:
I’ve read through that tutorial multiple times already and surprisingly I still couldn’t find the problem
Ah, but I’ve done some research and found a topic on the issue
Just how you would with not reserved server right? Like
local playerAmt = #game.Players:GetPlayers()
Edit: sorry i didn’t read the whole thing