This script doesn't seem to be putting players into random spots in the image labels. See this link below to see some of the info about it already:
https://scriptinghelpers.org/questions/2542/how-do-i-get-all-players-from-a-team-color-and-put-them-into-random-spots-of-a-image-label-once
but I have the gui check if it can find the other players leader gui first so it can not error and error if needed but when its all good and everything, the script only puts 1 person in one spot and doesnt put any other player in. Can someone help me?
script.Parent.Changed:connect(function() if script.Parent.Value == true then print("GreenKingGui On") local lk = game.Players:GetChildren() for k = 1, #lk do if lk[k]:FindFirstChild("King") and lk[k].TeamColor == BrickColor.new("Bright blue") and lk[k].PlayerGui:FindFirstChild("BlueKingGui") then print("Found Blue") elseif lk[k].PlayerGui:FindFirstChild("BlueKingGui") ~= nil then print("Error in gkg yesno") wait(1) game.Workspace:FindFirstChild("Round1").Er.Value = 2 end --end --end script.Parent.Parent.BackFrame.Visible = true print("Putting random slots for green") wait(0.2) local labels={[1] = script.Parent.Parent.BackFrame.Frame.PlayerSpot} local count=1 wait(0.5) for _,v in pairs(game.Players:GetPlayers())do if v.TeamColor==BrickColor.new("Bright green")and labels[count]then labels[count].PName.PlayName.Value=v.Name table.insert(labels,count,v.Name) count=count+1 print("Done putting slots for green") end end end elseif script.Parent.Value == false then print("GreenKingGui Off") script.Parent.Parent.BackFrame.Visible = false local l = script.Parent.Parent.BackFrame.Frame:GetChildren() for k = 1, #l do l[k].Name = "PlayerSpot" end end --end --end end)
For number of players on a team:
function GetNumPlayersOnATeam (color) count = 0 for i,v in pairs (game.Players:GetPlayers ()) do if v.TeamColor == color then count = count + 1 end end return count end GetNumPlayersOnATeam (BrickColor.new ('Really blue'))
For a table with all the player names of players on a team:
function GetTeamPlayersNames (color) teammates = {} for i,v in pairs (game.Players:getPlayers ()) do if v.TeamColor == color then table.insert (teammates, v.Name) end end return teammates end GetTeamPlayersNames (color)