How would I use the number of players to multiply a value by?

There was a topic with a similar name to this one but a different implementation altogether. My issue is that I have tried and failed to come up with a way to get the number of players.


local workSpace = game:GetService("Workspace")
local teams = game:GetService("Teams")
local playersHolder = {}


while true do
	if workSpace.Point1.pole1.BrickColor.Name == "Navy blue" and workSpace.Point2.pole2.BrickColor.Name == "Navy blue" then
		local playersCrips = teams.Crips:GetPlayers()
		for i, v in pairs(playersCrips)do
			if v:FindFirstChild("leaderstats") and v then
				v.leaderstats.Points.Value = v.leaderstats.Points.Value + 10
				table.insert(playersHolder, v)
				v.PlayerGui.ScreenGui.PointsDisplay.PointsCrips.Text = v.PlayerGui.ScreenGui.PointsDisplay.PointsCrips.Text * #playersHolder
			end
		end	

You can ignore the lack of ends towards the end there, this is part of a much larger script. The other parts of the script have already been tested and work fine. You can see that I tried to get the number of players by placing it into a table, but that doesn’t seem to work.

You can simply do:

#game.Players:GetPlayers()
1 Like

You wouldn’t happen to know how to get the total amount of a stat an entire team has would you? Like if a team has 60 points but each player has 20 points?

You can create a totalPoints variable initialized to 0. Then, retrieve the players in the team by doing team:GetPlayers(), iterate over that, access each player’s leaderstats and increment the value of the totalPoints by the value of the player’s points on each iteration.

1 Like