|
| 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 |
|
|
| |
|
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 |
|
|
|
| 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
|
  |
| 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 |
|
|
|
| 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
|
  |
| 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 |
|
|
|
| 30 Jul 2015 06:51 PM |
| will this print a person on the team every 8 seconds |
|
|
| Report Abuse |
|
|
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 |
|
|
|
| 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
|
  |
| 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 |
|
|
|
| 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 |
|
|
| |
|
|
| 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 |
|
|
|
| 30 Jul 2015 09:27 PM |
rip I wrote a function 99% similar on a different thread instawin
ʏᴏᴜ ᴛʜᴏᴜɢʜᴛ ʏᴏᴜ ᴄᴏᴜʟᴅ ᴅʀᴀɢ ᴍᴇ ᴛᴏ ᴛʜᴇ ʙᴏᴛᴛᴏᴍ ᴏғ ᴛʜᴇ ʟᴀᴋᴇ sᴏ ʏᴏᴜ ᴄᴏᴜʟᴅ ᴇᴀᴛ ᴍᴇ ʟᴀᴛᴇʀ... ᴡᴇʟʟ ɢᴜᴇss ᴡʜᴀᴛ ᴘᴜɴᴋ... ɪᴍ ᴀ ғɪsʜ... ᴡɪᴛʜ ʟᴇɢs |
|
|
| Report Abuse |
|
|
|
| 30 Jul 2015 09:28 PM |
| could u link me to that code? |
|
|
| Report Abuse |
|
|
| |
|
| |
|
|
| 31 Jul 2015 04:24 PM |
This thread is gonna get no help like a muthafka like a muthfka
|
|
|
| Report Abuse |
|
|
| |
|