Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 6 years ago
Edited 6 years ago

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

Log in to vote
0
Answered by
Leamir 3138 Moderation Voter Community Moderator
6 years ago
Edited 6 years ago

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

0
Ok, I'll try it, thanks for your help, I'll let you know how it works :) Skyraider5 -21 — 6y
0
HANGON. Local script? Bad and not fitering practical. H4X0MSYT 536 — 6y
0
Looking nowI think it can be a normal script Leamir 3138 — 6y
0
I tested, can be a normal script Leamir 3138 — 6y
View all comments (7 more)
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 Skyraider5 -21 — 6y
0
The second one now will aways be updated Leamir 3138 — 6y
0
(Every 3 seconds) Leamir 3138 — 6y
0
ok thanks i'll test it Skyraider5 -21 — 6y
0
This script works PERFECTLY, I can't even tell you what a HUGE help this has been, thank you so much Skyraider5 -21 — 6y
0
I know how you can say I helped, approve my answer Leamir 3138 — 6y
0
Oh dang, you're right totally forgot to do that my bad Skyraider5 -21 — 6y
Ad

Answer this question