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 » Scripting Helpers
Home Search
 

Re: table.insert convertion to string

Previous Thread :: Next Thread 
Raphael7 is not online. 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
TheDarkFireDragon is not online. TheDarkFireDragon
Joined: 02 Sep 2009
Total Posts: 1715
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 is not online. Raphael7
Joined: 03 Dec 2008
Total Posts: 2479
27 Jul 2011 01:23 PM
ty
Report Abuse
Dondonini is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. 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
TheDarkFireDragon is not online. TheDarkFireDragon
Joined: 02 Sep 2009
Total Posts: 1715
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
TheDarkFireDragon is not online. TheDarkFireDragon
Joined: 02 Sep 2009
Total Posts: 1715
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 is not online. 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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • 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