So i am trying to make a player count and i would like to make a feature such as (20) results show ( which is how many players are in the server. e.g. if theres 5 players the frame should say: (5) results.
I have tried using a int/num value to get this. Although if there’s another method to doing.
In JavaScript it’s .size which i am wondering if there is a method SIMILAR to that to gain the amount of frames.
Let me know any methods to getting so.
This should be able to change the number every second if the player joins or leaves.
function GetPlayerCount()
return #game.Players:GetPlayers() -- returns the number of players in the game currently
end
while wait() do
object.Text = "("..GetPlayerCount()..") results." -- Note ('object') is non existent, just an example.
end
Here’s a simple script I made for you that updates everytime a player leaves or join.
local Players = game:GetService("Players")
local GetPlayers = Players:GetChildren() -- get players
local TextUi = script.Parent
TextUi.Text = "There are " .. #GetPlayers " players in this server".
Players.PlayerAdded:Connect(function()
TextUi.Text = "There are " .. #GetPlayers " players in this server".
end
Players.PlayerRemoved:Connect(function()
TextUi.Text = "There are " .. #GetPlayers " players in this server".
end