Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do you make a GUI display the names of all the players in a certain team?

Hi, I'm having a ton of trouble with this script. I want to make a GUI like those GUIs in survival games where it pops up an has all of the names of the players who survived the round. I need my GUI to show the names of all of the players in a team called "Survivors". I have a script (below) but it doesn't work and I'm fairly sure that it is REALLY REALLY wrong so I could really use some help. This script is a regular script inside a text label that is inside of a frame inside the GUI. Thanks in advance, I really appreciate the help, if you have any questions please comment them below and I'll try to answer them ASAP.

local player = game.Teams.Survivors:GetPlayers()
while script.Parent.Parent.Parent.Parent.Enabled == true do
script.Parent.Text = print.player.Name
end

Again, I know this script sucks but I can't figure out how to fix it.

1 answer

✓ Accepted answer

Hello, Skyraider5!

I know how to make this, the following script will do exactaly that:

local teamcolor = "White" -- Team Color

for _, plr in pairs(game:GetService("Players"):GetPlayers()) do -- Gets all Players
	if plr.TeamColor == BrickColor.new(teamcolor) then -- Test every single player team  
		script.Parent.Text = plr.Name .. "," .. script.Parent.Text -- Sets the new label text!
	end
end

This script will get the current text of the box + player name(if in team)

ATTENTION: Script's parent must be the Label/Button it will edit!

I made this other script(This one don't need to be local, and can also be on the workspace =D)

local TeamName = "Team" -- Place the team name here!
local TeamColor = BrickColor.new("White")
local StartText = "Players in White team:" -- Change to the message gui will start with


script.Parent.Text = StartText

while wait() do
	local playersInt = game.Players:GetPlayers()
	local player = game.Players:GetChildren()
	local team = game:GetService("Teams"):FindFirstChild(TeamName)
	local players = team:GetPlayers()
	for i, plr in pairs(players) do
		if plr.TeamColor == TeamColor then
			script.Parent.Text = script.Parent.Text .. "," .. plr.Name
		end
		wait(3)
		if i == #playersInt then
			script.Parent.Text = StartText
		end
	end
end

~~ Edit: Added the second Script =D

Good Luck with your games

11 comments

0

Ok, I'll try it, thanks for your help, I'll let you know how it works :)

0

HANGON. Local script? Bad and not fitering practical.

0

Looking nowI think it can be a normal script

0

I tested, can be a normal script

0

Could you add a part at the beginning that makes it regenerate the names every second? Because right now it only works if the player starts out on the blue team but i need it to work if the player joined that team after spawning on another without respawning in between if that makes sense

0

The second one now will aways be updated

0

(Every 3 seconds)

0

ok thanks i'll test it

0

This script works PERFECTLY, I can't even tell you what a HUGE help this has been, thank you so much

0

I know how you can say I helped, approve my answer

0

Oh dang, you're right totally forgot to do that my bad

This discussion is preserved as it was. New answers, comments, and votes are closed.