How would I get the total of ALL players in a game without using HTTP service?

I am trying to add a script to my game, that if my total player count exceeds 10 it would display a message. But I am not sure how to do this since the MaxPlayers is 5.

I’ve been looking all over the place for this and everything says to use HTTPService and proxies and all that but that would leave my game vulnerable.

Does anyone know how?

What exactly are you trying to do?
Get the total number of active players in your game at any one point using the players in game?

And using HttpService wouldn’t leave your game vulnerable unless you coded it poorly and left backdoors or ways to run code.

I am trying to find the total numbers of players in my game. And HttpService is vulnerable because on the hacking site “v3rmillion” there is an exploit to take advantage of HttpService

You want to send me that? Because I’ve been doing web development since I was 9, and almost all of my recent projects have used HttpService and we have had no problems what so ever.

I’m not registered on the site but I have heard of it from exploiters and I have seen it used

I’m trying to find it on there but I can’t find anything.

I don’t know much about how exploits work and all that so I don’t know if it’s actually on there or not, I have seen many exploiters use it and one has showed me it but I didn’t copy it.

Exploiters can not do anything with HttpService unless you had a massive vulnerability and/or a backdoor.

2 Likes

Well I will still go with those posts because 2 people are now saying there is no vulnerability in HttpService. They were probably using a backdoor virus in the game or something along the lines of that.

No comment on background experience with exploits, but you’re pretty safe using HttpService.

There isn’t really much they can do other than send information about the game, item names, players who join and stuff.

Using HttpService doesn’t make your game vulnerable, otherwise no game on Roblox would be using it.

1 Like

I had a new developer ask me how I would go about doing this, and after spending an hour investigating the complexities of HttpService. I sorted out a simple solution via a DataStore, that does not suffer from server overwrite issues thanks to UpdateAsync().

This should work as requested.

local universeData = game:GetService("DataStoreService"):GetDataStore("universeMetadata") -- Reference or create datastore for our use (any name can be used)
--
local newCount, oldCount, countDiff; -- Creating local references
--
local function increment(oldValue) -- Safe icrementing function
	return math.clamp((oldValue or 0)+countDiff, 0, math.huge)
end;
--
local function updatePlayerCount(overrideCount)
	newCount = overrideCount or #game.Players:GetChildren(); oldCount = oldCount or 0;
	--
	if newCount ~= oldCount then
		countDiff = newCount-oldCount
		--
		oldCount = newCount;
		--
		local success, err = pcall(function()
			universeData:UpdateAsync('currentPlayers', increment)
		end)
	end
	--
	_G.currentPlayers = universeData:GetAsync('currentPlayers') or 0; -- We save the return for our own use in game, such as for a UI to reference. Global makes it easier;
	--
	print(_G.currentPlayers)
end;
-- 
game:BindToClose(function() -- We bind an override function to ensure the server will subtract all remaining players from the count on shutdown
	updatePlayerCount(0)
end)
--
while wait(10) do -- We use a single while loop at a reasonable frequency to prevent sending to many update requests.
	updatePlayerCount();
end;

Feel free to let me know if it works sufficiently :ok_hand: