Raphael7
|
  |
| Joined: 03 Dec 2008 |
| Total Posts: 2479 |
|
|
| 27 Jul 2011 01:20 PM |
Is there way to turn a table.insert to string? I have a script that's like this
Name={"","","","","",""}
game.Players.PlayerAdded:connect(function(newPlayer) newPlayer.CharacterAdded:connect(function(char) wait() table.insert(Name,newPlayer.Name) end ) end )
And I have a message script that will say the names, but it keeps saing numbers, like 1,2,3,4,5,6 |
|
|
| Report Abuse |
|
|
|
| 27 Jul 2011 01:22 PM |
Something like this...
Name = {}
game.Players.PlayerAdded:connect(function(newPlayer) newPlayer.CharacterAdded:connect(function(char)
wait() table.insert(Name, tostring(newPlayer.Name))
end) end) |
|
|
| Report Abuse |
|
|
Raphael7
|
  |
| Joined: 03 Dec 2008 |
| Total Posts: 2479 |
|
| |
|
Dondonini
|
  |
| Joined: 21 Dec 2007 |
| Total Posts: 734 |
|
|
| 27 Jul 2011 01:24 PM |
chain = "" for i = 1,#Name do chain = chain..", "..Name[i] end
print(chain)
and if you want a and at the last name here
chain = "" for i = 1,#Name do if i == #Name then chain = chain.." and "..Name[i] else chain = chain..", "..Name[i] end end
print(chain) |
|
|
| Report Abuse |
|
|
Raphael7
|
  |
| Joined: 03 Dec 2008 |
| Total Posts: 2479 |
|
|
| 27 Jul 2011 01:25 PM |
Btw would this work?
table.remove(Name, tostring(newPlayer.Name))
|
|
|
| Report Abuse |
|
|
Dondonini
|
  |
| Joined: 21 Dec 2007 |
| Total Posts: 734 |
|
|
| 27 Jul 2011 01:25 PM |
| aww i was too late XD oh well |
|
|
| Report Abuse |
|
|
Dondonini
|
  |
| Joined: 21 Dec 2007 |
| Total Posts: 734 |
|
|
| 27 Jul 2011 01:27 PM |
no
table.remove([the table name], [number])
so if the table was blah = {1,2,3,4}
and i used table.remove(blah,3)
then the table will be blah = {1,2,4} |
|
|
| Report Abuse |
|
|
Raphael7
|
  |
| Joined: 03 Dec 2008 |
| Total Posts: 2479 |
|
|
| 27 Jul 2011 01:33 PM |
| But how'd you figure out the number where you put the player's name |
|
|
| Report Abuse |
|
|
|
| 27 Jul 2011 01:37 PM |
Just to be more clear, table.remove removes the value at the specified position. For example:
myTable = {'a', 'b', 'c'} table.remove(myTable, 2) print (table.concat(myTable, ' ')) --> a c
|
|
|
| Report Abuse |
|
|
|
| 27 Jul 2011 01:39 PM |
@OP
When do you want to remove a player? In your example, the numbers will go by the order players join. |
|
|
| Report Abuse |
|
|
Raphael7
|
  |
| Joined: 03 Dec 2008 |
| Total Posts: 2479 |
|
|
| 27 Jul 2011 01:45 PM |
Well, I'm not so sure, my real script is where someone dies, it removes their name from the list. But I can't do that because I'm not sure. So let's say I have this
Name = {}
if p[i].Life.Value==1 then table.insert(Name, tostring(p[i].Name)) elseif p[i].Life.Valu==0 then table.remove(Name, ?) -- That part Idk end
But the thing is, when the script runs it would change to this
Name = {"Player", "Noob"} -- How would I remove the "Noob" if the Noob dies?
if p[i].Life.Value==1 then table.insert(Name, tostring(p[i].Name)) elseif p[i].Life.Valu==0 then table.remove(Name, ?) -- That part Idk end |
|
|
| Report Abuse |
|
|