Hello everyone, today we would like to have your help on Roblox Studio in scripting. We want a player counter on a game owned by us. We tried this script but it doesn’t work. Can you help us please ?
What’s that AssetID
for? Seems like you should be using a LocalScript
to count the number of players. Something like this:
local playersServ = game:GetService("Players")
local textlabel = --the label you want to display the number of players in
playersServ.PlayerAdded:Connect(function()
textlabel.Text = "Player count: "..#playersServ:GetPlayers()
end)
playersServ.PlayerRemoving:Connect(function()
textlabel.Text = "Player count: "..#playersServ:GetPlayers()
end)
textlabel.Text = "Player count:"..#playersServ:GetPlayers()
Hi, you misunderstood… We want the player count of a game other than the server.
Not sure how to solve this, but you could check the above link out! I’ll keep digging…
This script is used to count the players of the game and not of another game
Oh well. Sorry, I can’t help you. Forgive me, I’m not a pro at scripting. Good luck with your game!
i dont really understand you, are you using google translate?
also do you mean getting the total amount of players in a game and not a server?
then you can use a proxy and use roblox’s games api to do that
https://games.roblox.com/docs#!/Games/get_v1_games
Can you give us an example, we don’t quite understand what to put in the script?
The PlayerAdded event and GetPlayers function only works on server side, causing the problem.
Code:
local PlayerService = game:GetService("Players")
local RunService = game:GetService("RunService")
local PlayerCounterGui = script.Parent
local TextLabel = PlayerCounterGui.TextLabel
RunService.RenderStepped:Connect(function()
local PlayerAmount = CheckPlayerAmount()
TextLabel.Text = "Players: ".. PlayerAmount
end)
function CheckPlayerAmount()
local PlayerAmount = 0
for i, v in pairs(game:GetDescendants()) do
if (v:IsA("Humanoid")) then
if (PlayerService:GetPlayerFromCharacter(v.Parent)) then
PlayerAmount += 1
end
end
end
return PlayerAmount
end
Result:
Works with NPCs.
he said he wants GLOBAL players count, not CURRENT server players count.
You would need to use messaging service for that
This has already been solved here:
Hello ,Where to put the id of the place? We don’t quite understand how to do this… Can you help us knowing that the id of the place is 7354654701 and we want all the players of this place.