How do I make this work in a Script, not a LocalScript?
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)
p.s I want to have a count of the players!
Try
function GetPlayersOnTeam(Color) local Players={} for i,v in pairs(game.Players:GetChildren()) do if v.ClassName=="Player" then if v.TeamColor.Name==Color then table.insert(Players,v) end end end return Players end coroutine.wrap(function() while wait() do hn=#GetPlayersOnTeam("Bright blue") sn=#GetPlayersOnTeam("Dark stone grey") end end)()