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: Math.random table help

Previous Thread :: Next Thread 
EMAN381 is not online. EMAN381
Joined: 27 Nov 2007
Total Posts: 4300
27 Oct 2011 07:46 PM
chats = {"hey", "hello", "hi"}
while true do
for i=1, #chats do
game:GetService("Chat"):Chat(script.Parent, math.random(chats[i]),Enum.ChatColor.Blue) --This does not work.
wait(5)
end
wait(3)
end

--Workspace.Head.Script:4: bad argument #1 to 'random' (number expected, got string)
Report Abuse
Seranok is not online. Seranok
Joined: 12 Dec 2009
Total Posts: 11083
27 Oct 2011 07:48 PM
chats[math.random(i)]

You had the right idea. Btw you're epic.
Report Abuse
TheNewScripter is not online. TheNewScripter
Joined: 02 Mar 2010
Total Posts: 2432
27 Oct 2011 07:48 PM
math.random() requires numbers, not a table... If you want it to chat Randomly, then just use this:

chats = {"hey", "hello", "hi"}

while not false do
local ChatText = chats[math.random(1, #chats)]
Game:GetService("Chat"):Chat(script.Parent, ChatText, Enum.ChatColor.Blue)
wait(8)
end
Report Abuse
EMAN381 is not online. EMAN381
Joined: 27 Nov 2007
Total Posts: 4300
27 Oct 2011 07:50 PM
Thank you. :D
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