So far I tried to make the for i loop count, but it wouldn't work. It would instead just show as a label with the text implying "label" how would I overcome this issue?
01 | local plr = game.Players.LocalPlayer |
02 | local s = Instance.new( "ScreenGui" ) |
03 | s.Name = "AIGui" |
04 | s.Parent = plr:WaitForChild( "PlayerGui" ) |
05 | local f = Instance.new( "Frame" ,s) |
06 | f.Size = UDim 2. new( 0 , 400 , 0 , 250 ) |
07 | f.Position = UDim 2. new( 0 , 540 , 0 , 100 ) |
08 | f.BackgroundColor 3 = Color 3. new( 255 , 0 , 0 ) |
09 | f.BackgroundTransparency = 0.7 |
10 | wait( 1 ) |
11 | local tl = Instance.new( "TextLabel" ,f) |
12 | tl.Position = UDim 2. new( 0 , 50 , 0 , 165 ) |
13 | tl.TextSize = 15 |
14 | local a = game.Teams.Raiders:GetChildren() |
15 | for i = 1 , #a do |
16 | tl.Text = AI.. ":" ..i |
17 | end |
01 | local Team = { game.Teams.Raiders,game.Teams. [ "EnterOtherTeamNameHere" ] } |
02 |
03 | local x |
04 | local y |
05 |
06 | for _, Player in pairs (game.Players:GetChildren()) do |
07 | if Player.Team = = Team [ 1 ] then |
08 | x = x + 1 |
09 | --Do whatever |
10 | elseif Player.Team = = Team [ 2 ] then |
11 | y = y + 1 |
12 | --Do whatever |
13 | end |
14 | end |
15 |
16 | tl.Text = AI.. ":" ..x |
You will probably need to modify this to be compatible with your script.
If I understand your question correctly, you want to get the number of players.
1 | local numOfPlrs = #game.Players:GetChildren() |
2 |
3 | tl.Text = AI .. ":" .. numOfPlrs |
NOTE: This won't change if players leave or join. So you just have to create a function that updates the Text. And hook up event listeners to it.