Player Count in Hub

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!

I want to create a hub for players to easily travel throughout my games. (Football games like Madden) And for the players who don’t know what stadium we are playing at, I want a player count system that provide the number count.

  1. What is the issue? Include screenshots / videos if possible!

Well, I’m not a great scripter. I’ve also looked for tutorials, and open-sourced scripts.

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

I’ve found a few scripts, but it doesn’t match my needs.

local p = game.Players.NumPlayers
local t = script.Parent.Text
local text = ("Players are in the server!")
while true do
if p == 1 then
	script.Parent.Text = (p.." Player is in the server!")
else
	script.Parent.Text = (p.."Players are in the server!")
	end
	wait(10)
end

It shows the current game players. I need a script that can track a different PlaceId’s players. Is that possible?

Like if I was to alter the script like this;

local placeid = 0000000
local p = game.placeid.Players.NumPlayers
local t = script.Parent.Text
local text = ("Players are in the server!")
while true do
if p == 1 then
	script.Parent.Text = (p.." Player is in the server!")
else
	script.Parent.Text = (p.."Players are in the server!")
	end
	wait(10)
end

This doesn’t work obviously, so can I get some help? Thanks.

2 Likes

not a local script …

local players = 0
game.Players.PlayerAdded:Connect(function(player)
	players +=1
end)
game.Players.PlayerRemoving:Connect(function(player)
	players -=1
end)

didn’t test this … it can be done something like this

1 Like

How can I run this script to get other placeid’s? Like a place inside an experience. Not the current game.

1 Like

Well … you could do that in a script all by itself on the main game.
Then you would know how many are in the game total …
After that it would be a matter of counting how many went where as they ported.
Never tried anyhting like this so … only problem I can see with it would be if they left from a ported to place. I’m thinking a datastore could be used here … Would have to do a bunch of testing.

1 Like

Try using MessagingService to send over the amount of players from each server.

1 Like

I can use a MessagingService to grab other places NumPlayers?

So, I have a nice starting script.

function Changed()
	script.Parent.Text = game.Players.NumPlayers.." Players"
end

function Changed2()
	script.Parent.Text = game.Players.NumPlayers.." Players"
end

game.Players.PlayerAdded:connect(Changed)
game.Players.PlayerRemoving:connect(Changed2)

This works great, but it only grabs the current games NumPlayers.

I’m trying to figure out a way to grab a different placeid’s player count.

1 Like