function getPlayersOnTeam(teamColor) local players = {}; for i,v in pairs(game.Players:GetPlayers()) do if (v.TeamColor.Name == teamColor) then table.insert(players, v); end end return players end; game:GetService("RunService").RenderStepped:connect(function() hn = #getPlayersOnTeam("Bright blue"); sn = #getPlayersOnTeam("Dark stone grey"); end)
I want this code to work in a Script, not a LocalScript. How would I make it work? [I want the code to work so that it constantly updates the count of players on each team]
This is the same code, but just easier to read:
function getPlayersOnTeam(teamColor) local players = {} for i, v in pairs(game.Players:GetPlayers()) do if v.TeamColor.Name == teamColor then table.insert(players, v) end end return players end game:GetService("RunService").RenderStepped:connect(function() hn = #getPlayersOnTeam("Bright blue") sn = #getPlayersOnTeam("Dark stone grey") end)
So, it doesn't work?
If it's not working, and you're trying to run it from a server script, I believe that RenderStepped is only able to be used in LocalScripts. Correct me if I'm wrong.