Player Count (Ask)

Is there any way to get Player Count or (Total Player) who come into my game for a day? Like this day 200 so every 00:00 the next day it will print the player count for previous day. Same to the next day.
Like let’s say today is Monday, and on Monday i get 200 players total, and on Tuesday 00:00 it will print total players on monday, same to the next day, on Tuesday I get 300 it will print total players of tuesday on Wednesday 00:00 and on next week Monday 00:00 it will total from last Monday to Sunday.

And after that resetting again.

Utilize data stores for this.
Introduction to Saving Data (roblox.com)

Is this for something to be used within your game? Or for you to see? There are statistics for this Roblox themselves provide to the developer of a place.

1 Like

I don’t think you can do that in-game, But you can check that on your game’s Developer Stats. (Find your game on the Roblox Website, Click on the 3 dots … and then click on Developer Statistics) It also comes with alot of more information, Such as average players per day/week/month, Average time that a Player spends in your game etc.

Yes but I want to make it in-game so admin or player can check it without have to access browser.

Well yes but i want it so player/admin can check it in game without have to access browser. Is it possible?

Like i said, I don’t think you can do that in-game. Saving it on a DataStore would be messy as it would take alot of Memory if alot of Players join and to wipe Data. (It would need to do that on Every server basically) The best thing you could try is using a Proxy and send a HttpRequest and retrieve Data and see what you can do. I’m not the best at HttpRequests so i don’t know if you’re able to do that. Also, It’s basically impossible to do that without needing to open your browser.

1 Like

So I supposed that’s a little bit possible but it would take tons of memories, yes?

It’s possible.

-- Pseudo code:
game.Players.PlayerAdded:Connect(function(plr)
	local todaysVisitors = -- get todays visits
	-- Check if current time is on the next day
		-- compared to lastSavedTime
	-- If it's the next day, then set previousVisitors
		-- to the # todaysVisitors. Empty the list
		-- of todays visitors on the datastore
		todaysVisitors = {}
	if plr.UserId in todaysVisitors then
		-- Do nothing. Player is already added to the list.
	else
		-- Add player to data store.
		-- Save the current time to lastSavedTime
	end
end)
1 Like

Or is it possible to make two values using datastore so when player added it will add one to the first values (todayValues) and check if it’s already 00:00 of the next day it will plus the totalValues and reset the todayValues to 0?

What about loading the table? What about the DataStore Limits? Please, Elaborate and understand what i’m trying to say. You can indeed do that but doing it would basically break your game as loading the Data would take alot of time and plus saving it with alot of Players would probably fill the DataStore Limit.


DataStoreDataLimits

You could maybe try creating and hosting your own Server to do WebRequests but that would take alot of time plus despiting the fact anyone could send a DDoS attack to it.
If you want to do that, Then do it. But don’t get surprised if your game DataStores throw errors or Data gets lost.

So I’m supposing it only works if you have small players game? I mean not that famous game that has like 100K players, but it can if like yeah a day you only get 100 or less players.

I mean both works but with less risk.

I think you need to store 3 values. Since your server wont be on every second (most likely, unless you have a fairly popular game) it won’t be active when it reaches 00:00.

todaysVisitors { userId’s } – Prevent storing of already stored user
lastSavedTime { dateTime} – Used to calculate if today is the next day
previousVisitors {number] – Used to display amount of visitors you had previous day.

Regarding @MeCrunchAstroX’s concerns regarding the data limits, you will only request it once every player joins. Since your request limit is 60 + 10 * Players you have more than enough.

The only limit you may need to worry about is the Data limit. (4´000´000 characters is a lot though).

IF you run out of space on your data limit, then simply create a backup key “todaysVisitors2” or something. You have now doubled your storage.

Speed will most likely not be an issue either, since loading data is Async.

Ah no i don’t need player userId tho, I just need the amount(numerical)

You need the userId if you don’t want to calculate unique visitors. You don’t need to otherwise.

I mean I don’t need to store player UserId on the table I just need to know the amount of player that comes to the game.

Ahhh yes. Limit………
But Yes………

Well, Using Regular DataStores would be a bad idea for this, But maybe trying using ProfileService could solve most of those problems? Since ProfileService was specially made for saving and loading data fastly and without needing to worry about limits.

Ahh thank you, yes I know about profile service.