Player Counter GUI, a bit complicated

you can use a proxy or use MessagingService to communicate with the main place; in this case requesting the player count.

main place pseudocode:

onMessageReceived(topic = "playerCountUpdate", message) -- equivalent to SubscribeAsync
> -- either use IntValues or use RemoteEvents to update the player count in your gui
> local PlacePlayerCountIntValue = GetPlacePlayerCountReference(message.Data.PlaceId) -- a function to get the int value for the place's player count
> PlacePlayerCountIntValue.Value = message.Data.NewPlayerCount -- set the new player count for the map

map places pseudocode:

-- because messagingservice sometimes doesn't guarantee a message deliver sucessfully, we will use intervals
onPlayerAdded(player) -- game.Players.PlayerAdded
> local CurrentPlayers = Players:GetPlayers()
> local CurrentPlayersCount = #CurrentPlayers

> MessagingService:PublishAsync("playerCountUpdate", {NewPlayerCount = CurrentPlayersCount, PlaceId = game.PlaceId}) -- send the new data with the new player count and the place id
1 Like