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: How would I?(Tables)

Previous Thread :: Next Thread 
Sharpshooter26 is not online. Sharpshooter26
Joined: 26 May 2010
Total Posts: 5166
12 Jan 2013 05:31 PM
I have this so far:

game.Players.PlayerAdded:connect(function(player)
function talked (msg)
msg:lower()
if msg ==



end

player.Chatted:connect(talked)

What I want to do is make a table and have the if msg == cycle through the table to see if what the player said is one of the words in the table and recognize what that word is.
Report Abuse
LFMEB is not online. LFMEB
Joined: 31 May 2012
Total Posts: 66
12 Jan 2013 05:33 PM
You're a newb.
Report Abuse
Sharpshooter26 is not online. Sharpshooter26
Joined: 26 May 2010
Total Posts: 5166
12 Jan 2013 05:34 PM
I am not a noob, I just have never dealt with tables before.
Report Abuse
Saltless is not online. Saltless
Joined: 24 Dec 2012
Total Posts: 107
12 Jan 2013 05:36 PM
u r nob (pls dont reveal my identitee if u no et)

allowedWords = { "Word1", "Word2", "SoOn"} -- Put these lower case if using :lower()

game.Players.PlayerAdded:connect(function(player)
player.Chatted:connect(function(chat)
local msg = chat:lower()
for i = 1, #allowedWords do
if msg == allowedWords[i] do
-- col stoof
end
end)
end)

-- A fry without salt is like a world without hate.
Report Abuse
LFMEB is not online. LFMEB
Joined: 31 May 2012
Total Posts: 66
12 Jan 2013 05:37 PM
player.Chatted:connect(function(string)
for i, v in pairs(words) do
if string:lower() == v:lower() then

end
end
end)
Report Abuse
CodyTheBuildingKid is not online. CodyTheBuildingKid
Joined: 13 Dec 2011
Total Posts: 4399
12 Jan 2013 05:39 PM
No.


Words = { "1", "2", "3", "etc"}

game.Players.PlayerAdded:connect(function(player)
player.Chatted:connect(function(chat)
local msg = chat:lower()
for i = 1, #Words do
if msg == Words[i]:lower() do
-- col stoof
end
end
end)
end)
Report Abuse
LFMEB is not online. LFMEB
Joined: 31 May 2012
Total Posts: 66
12 Jan 2013 05:40 PM
Nice code, it's inefficient.
Report Abuse
CodyTheBuildingKid is not online. CodyTheBuildingKid
Joined: 13 Dec 2011
Total Posts: 4399
12 Jan 2013 05:41 PM
Inefficiency ~= Less letters
Report Abuse
LFMEB is not online. LFMEB
Joined: 31 May 2012
Total Posts: 66
12 Jan 2013 05:42 PM
local msg = chat:lower()

Useless.
Report Abuse
CodyTheBuildingKid is not online. CodyTheBuildingKid
Joined: 13 Dec 2011
Total Posts: 4399
12 Jan 2013 05:44 PM
Not necessarily useless.
But if you must, you could remove that and add it to the check.

if chat:lower() == Words[i]:lower() then

Not useless, just a preference.
Report Abuse
CodyTheBuildingKid is not online. CodyTheBuildingKid
Joined: 13 Dec 2011
Total Posts: 4399
12 Jan 2013 05:46 PM
Ahh, mistakes I can see.

Words = { "1", "2", "3", "etc"}

game.Players.PlayerAdded:connect(function(player)
player.Chatted:connect(function(chat)
for i,v in ipairs(Words) do
if chat:lower() == v:lower() then
-- Code
end
end
end)
end)
Report Abuse
LFMEB is not online. LFMEB
Joined: 31 May 2012
Total Posts: 66
12 Jan 2013 05:47 PM
New variable was what I meant.
Report Abuse
CodyTheBuildingKid is not online. CodyTheBuildingKid
Joined: 13 Dec 2011
Total Posts: 4399
12 Jan 2013 05:51 PM
New variables aren't inefficient, it's just placing a piece of code somewhere ahead of time.
Report Abuse
Sharpshooter26 is not online. Sharpshooter26
Joined: 26 May 2010
Total Posts: 5166
12 Jan 2013 06:59 PM
What does this mean?

if chat:lower() == v:lower() then
Report Abuse
yomamadude6 is not online. yomamadude6
Joined: 21 Nov 2009
Total Posts: 2151
12 Jan 2013 07:05 PM
turns it both into lowercased for easier comparison
Report Abuse
Sharpshooter26 is not online. Sharpshooter26
Joined: 26 May 2010
Total Posts: 5166
12 Jan 2013 07:11 PM
Oh nevermind all it does is lower each variable and see if they are alike, I want to find out which one it is though, not if it is one of them.


Like if a guy chats 1 then the function will run, but I don't know if he said 1, 2 ,3 or etc.
Report Abuse
Sharpshooter26 is not online. Sharpshooter26
Joined: 26 May 2010
Total Posts: 5166
12 Jan 2013 07:19 PM
Help please?
Report Abuse
CodyTheBuildingKid is not online. CodyTheBuildingKid
Joined: 13 Dec 2011
Total Posts: 4399
12 Jan 2013 08:54 PM
Words = { "1", "2", "3", "etc"}

game.Players.PlayerAdded:connect(function(player)
player.Chatted:connect(function(chat)
if chat:lower() == Words[1]:lower() then
-- Code
elseif chat:lower() == Words[2]:lower() then
--Code
end
end)
end)
Report Abuse
Sharpshooter26 is not online. Sharpshooter26
Joined: 26 May 2010
Total Posts: 5166
12 Jan 2013 09:50 PM
@cody'


omg how you learn so much qq
Report Abuse
CodyTheBuildingKid is not online. CodyTheBuildingKid
Joined: 13 Dec 2011
Total Posts: 4399
12 Jan 2013 09:54 PM
I may be able to do this, but I get lost when I try hopperbins. qq
Report Abuse
Sharpshooter26 is not online. Sharpshooter26
Joined: 26 May 2010
Total Posts: 5166
12 Jan 2013 10:01 PM
lol, I never liked tables and all this crap, I enjoy tools and guis alot more.
Report Abuse
Sharpshooter26 is not online. Sharpshooter26
Joined: 26 May 2010
Total Posts: 5166
12 Jan 2013 10:05 PM
Does Words[1] mean the first part of the table or the thing named 1?
Report Abuse
CodyTheBuildingKid is not online. CodyTheBuildingKid
Joined: 13 Dec 2011
Total Posts: 4399
12 Jan 2013 10:06 PM
Really? I prefer tables and this 'crap'. :D
Hopperbins don't interest me. Guis are alright.

Report Abuse
CodyTheBuildingKid is not online. CodyTheBuildingKid
Joined: 13 Dec 2011
Total Posts: 4399
12 Jan 2013 10:08 PM
The first part.

Words = {"Hello", "noob"}

print(Words[1],Words[2])

>Hello noob
Report Abuse
Usering is not online. Usering
Joined: 18 Aug 2012
Total Posts: 10281
12 Jan 2013 10:12 PM
@cody,

script.Parent.Selected:connect(function(mouse)
mouse.Button1Down:connect(function()
if mouse.Target then print(mouse.Target) end
end)
end)

- What have the mini-mods come to nowadays? -
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