generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: Getting Players

Previous Thread :: Next Thread 
SirIngenuity is not online. SirIngenuity
Joined: 06 Oct 2012
Total Posts: 3149
30 Jul 2015 04:29 PM
How can I get each player on team.

For instance, I need help with script that. Will go through everyone on "Bright red" team. And if player is on red team thenit displays there name

like

"Please welcome" ..RedTeamPlayer.."!"
etc
for all the players on red team and it doesn't repeat a player thats went
Report Abuse
SirIngenuity is not online. SirIngenuity
Joined: 06 Oct 2012
Total Posts: 3149
30 Jul 2015 05:24 PM
bring up my post
Report Abuse
instawin is not online. instawin
Joined: 04 Jun 2013
Total Posts: 8777
30 Jul 2015 05:37 PM
function getPlrsOnTeam(teamColor)
local teammates = {}
for i, v in pairs(game.Players:GetPlayers()) do
if v.TeamColor == BrickColor.new(teamColor) then
table.insert(teammates, v)
end
end
return teammates
end

for i, v in pairs(getPlrsOnTeam("Bright red")) do
print(v.Name.." is on the Bright red team!")
end
Report Abuse
SirIngenuity is not online. SirIngenuity
Joined: 06 Oct 2012
Total Posts: 3149
30 Jul 2015 05:38 PM
^ I know how to for, v ... get players on team. I need something thats more advance.

How to individually call out players on team and keeps calling them out until all players have been called out and I need it not to repeat people
Report Abuse
instawin is not online. instawin
Joined: 04 Jun 2013
Total Posts: 8777
30 Jul 2015 05:46 PM
"How can I get each player on team."

i wrote you a function that gets all the players in the provided teamcolor. that's what you asked for.

not writing your whole script man

"^ I know how to for, v ... get players on team. I need something thats more advance.

How to individually call out players on team and keeps calling them out until all players have been called out and I need it not to repeat people"

what? i don't understand what you are asking now.

do you mean this?

-- put my function above this
for i, team in pairs(game.Teams:GetChildren()) do
for ii, teammate in pairs(getPlrsOnTeam(team.TeamColor)) do
print(teammate.Name.." is on the "..tostring(team.TeamColor).." team!")
end
end

would print out the names of all the teammates in each team i believe
Report Abuse
SirIngenuity is not online. SirIngenuity
Joined: 06 Oct 2012
Total Posts: 3149
30 Jul 2015 06:31 PM
Thank you,

I probably came off as dk. Ok now that we have code that tells everyone whose on whose team how can I want to call out players

Current Script:
function getPlrsOnTeam(teamColor)
local teammates = {}
for i, v in pairs(game.Players:GetPlayers()) do
if v.TeamColor == BrickColor.new("Bright green") then
table.insert(teammates, v)
end
end
return teammates
end

for i, team in pairs(game.Teams:GetChildren()) do
for ii, teammate in pairs(getPlrsOnTeam(team.TeamColor)) do
print(teammate.Name.." is on the "..tostring(team.TeamColor).." team!")
end
end

The script prints everyones name out at once. How can I call out player wait 8 seconds call out next player wait 8 etc etc etc
Report Abuse
instawin is not online. instawin
Joined: 04 Jun 2013
Total Posts: 8777
30 Jul 2015 06:49 PM
"if v.TeamColor == BrickColor.new("Bright green") then"

replace that with teamColor

if v.TeamColor == BrickColor.new(teamColor)

the function is supposed to take the argument you feed it, which should be a string of a BrickColor name. what that line does there is checks if the player's teamcolor is equal to the TeamColor string you provided


for i, team in pairs(game.Teams:GetChildren()) do
for ii, teammate in pairs(getPlrsOnTeam(team.TeamColor)) do
wait(8)
print(teammate.Name.." is on the "..tostring(team.TeamColor).." team!")
end
end
Report Abuse
SirIngenuity is not online. SirIngenuity
Joined: 06 Oct 2012
Total Posts: 3149
30 Jul 2015 06:51 PM
will this print a person on the team every 8 seconds
Report Abuse
instawin is not online. instawin
Joined: 04 Jun 2013
Total Posts: 8777
30 Jul 2015 06:52 PM
it will wait 8 seconds between printing the player that is in the current team it is looping through
Report Abuse
SirIngenuity is not online. SirIngenuity
Joined: 06 Oct 2012
Total Posts: 3149
30 Jul 2015 06:55 PM
Lol thanks it works. perfectly

Final Code:
function getPlrsOnTeam(teamColor)
local teammates = {}
for i, v in pairs(game.Players:GetPlayers()) do
if v.TeamColor == BrickColor.new("Bright green") then
table.insert(teammates, v)
end
end
return teammates
end

for i, team in pairs(game.Teams:GetChildren()) do
for ii, teammate in pairs(getPlrsOnTeam(team.TeamColor)) do
print(teammate.Name.." is on the "..tostring(team.TeamColor).." team!")
end
end

Why do u want me to change this?
if v.TeamColor == BrickColor.new("Bright green") then

^ that works fine
Report Abuse
instawin is not online. instawin
Joined: 04 Jun 2013
Total Posts: 8777
30 Jul 2015 07:05 PM
i just explained why

if v.TeamColor == BrickColor.new(teamColor)

notice, the function's parameter is named teamColor. what this line does is compares if the player's teamcolor is the same as the TeamColor you wanted the function to check for.

Report Abuse
SirIngenuity is not online. SirIngenuity
Joined: 06 Oct 2012
Total Posts: 3149
30 Jul 2015 08:51 PM
So where would I add what team color I want it to check for

function getPlrsOnTeam(teamColor)
local teammates = {}
for i, v in pairs(game.Players:GetPlayers()) do
if v.TeamColor == BrickColor.new(teamColor) then
table.insert(teammates, v)
end
end
return teammates
end

for i, team in pairs(game.Teams:GetChildren()) do
for ii, teammate in pairs(getPlrsOnTeam(team.TeamColor)) do
wait(8)
print(teammate.Name.." is on the "..tostring(team.TeamColor).." team!")
end
end
Report Abuse
SirIngenuity is not online. SirIngenuity
Joined: 06 Oct 2012
Total Posts: 3149
30 Jul 2015 09:09 PM
.
Report Abuse
SirIngenuity is not online. SirIngenuity
Joined: 06 Oct 2012
Total Posts: 3149
30 Jul 2015 09:25 PM
Cmon guys I'm sure instawin isn't the only person who is capable enough to help me :/
Report Abuse
cooldude999921 is not online. cooldude999921
Joined: 13 Aug 2011
Total Posts: 3702
30 Jul 2015 09:27 PM
rip I wrote a function 99% similar on a different thread instawin

ʏᴏᴜ ᴛʜᴏᴜɢʜᴛ ʏᴏᴜ ᴄᴏᴜʟᴅ ᴅʀᴀɢ ᴍᴇ ᴛᴏ ᴛʜᴇ ʙᴏᴛᴛᴏᴍ ᴏғ ᴛʜᴇ ʟᴀᴋᴇ sᴏ ʏᴏᴜ ᴄᴏᴜʟᴅ ᴇᴀᴛ ᴍᴇ ʟᴀᴛᴇʀ... ᴡᴇʟʟ ɢᴜᴇss ᴡʜᴀᴛ ᴘᴜɴᴋ... ɪᴍ ᴀ ғɪsʜ... ᴡɪᴛʜ ʟᴇɢs
Report Abuse
SirIngenuity is not online. SirIngenuity
Joined: 06 Oct 2012
Total Posts: 3149
30 Jul 2015 09:28 PM
could u link me to that code?
Report Abuse
SirIngenuity is not online. SirIngenuity
Joined: 06 Oct 2012
Total Posts: 3149
30 Jul 2015 09:40 PM
bump
Report Abuse
SirIngenuity is not online. SirIngenuity
Joined: 06 Oct 2012
Total Posts: 3149
31 Jul 2015 04:18 PM
asdadfe
Report Abuse
SirIngenuity is not online. SirIngenuity
Joined: 06 Oct 2012
Total Posts: 3149
31 Jul 2015 04:24 PM
This thread is gonna get no help like a muthafka like a muthfka
Report Abuse
SirIngenuity is not online. SirIngenuity
Joined: 06 Oct 2012
Total Posts: 3149
31 Jul 2015 06:47 PM
bump instawin is online~
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image