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: Using a table which contains sentences, selecting one.

Previous Thread :: Next Thread 
MARIOSTAR6464 is not online. MARIOSTAR6464
Joined: 21 Jul 2008
Total Posts: 13674
17 Sep 2012 11:20 AM
Let's take for example


Table = {"Hello there.", "Goodbye for now"}

function a()

script.Parent.Name = math.random(1, #Table)

end



My problem is that rather than getting the text like 'Hello there.', instead I get numbers like 1, 2, etc.




I've been away from scripting a while so I'm pretty rusty, so what should I do?
Report Abuse
1pie23 is not online. 1pie23
Joined: 11 Jul 2010
Total Posts: 1865
17 Sep 2012 11:21 AM
Table = {"Hello there.", "Goodbye for now"}

function a()
ma = math.random(1, #Table)

script.Parent.Name = Table[ma]

end
Report Abuse
nate890 is not online. nate890
Joined: 22 Nov 2008
Total Posts: 21686
17 Sep 2012 11:23 AM
Ok, that's because you're getting a random number from 1 - the amount of items in Table.

Which is a start, but to finish that off we need to index the random number that we got and put it to good use, like such:

    script.Parent.Name = Table[math.random(#Table)]

good luck!
Report Abuse
rudolph101 is not online. rudolph101
Joined: 15 Jan 2009
Total Posts: 11873
17 Sep 2012 11:23 AM
I'm not sure if this is completely correct, but I'm hoping if I'm wrong, and you've done this before, that it might at least help you remember.


Table = {"Hello there.", "Goodbye for now"}

function a()

for i,v in pairs{Table}
print(v)
end
end
Report Abuse
MARIOSTAR6464 is not online. MARIOSTAR6464
Joined: 21 Jul 2008
Total Posts: 13674
17 Sep 2012 11:25 AM
Ah yes, that was it, thanks.
Report Abuse
rudolph101 is not online. rudolph101
Joined: 15 Jan 2009
Total Posts: 11873
17 Sep 2012 11:28 AM
@Mario

Which one was it?
Report Abuse
nate890 is not online. nate890
Joined: 22 Nov 2008
Total Posts: 21686
17 Sep 2012 01:27 PM
Your code doesn't do what it appears he is wanting to do. So probably not your code.
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