Thank you to RayCurse for creating the code, you can see his post here.
Although this is a script helping site not a script developing site, I can give some advice.
Inside a script, you can use this to count the current amount of players:
local playerCount = #game.Players:GetPlayers()
GetPlayers() returns a table of all Players objects. The # (length operator) is used to get the length of the table returned.
Then use that information to set a textlabel's text to that amount.
(using tostring(), since we're dealing with numbers not strings.)
Now for updating the amount for whenever someone enters or leaves the game.
We can use the following code:
game.Players.PlayerAdded:Connect(function()
playerCount = playerCount + 1
end)
game.Players.PlayerRemoving:Connect(function()
playerCount = playerCount - 1
end)
To detect when a player is joining and leaving the game.
Hopefully this answered your question!
If I have incorrectly answered this, feel free to correct me in the comments of this answer.