Hi guys, I want to make a commands script, so when you chat something, you get the appropriate result.
I is really time consuming if I check weather the message chatted by player is the command or not, writing 3 lines of code for each command! D:
How do I write it more efficiently? I though of using a table which contains commands and the relative subjects.
Here's my table. It changes faces
local Faces = {
Smile = "http://www.roblox.com/asset/?id=7137738",
AngryMin = "http://www.roblox.com/asset/?id=7079958",
AngryMid = "http://www.roblox.com/asset/?id=7137750",
AngryMax = "http://www.roblox.com/asset/?id=7604619",
Kind = "http://www.roblox.com/asset/?id=7604617",
HappyMin = "http://www.roblox.com/asset/?id=7079953",
HappyMax = "http://www.roblox.com/asset/?id=7604621"
}
and then, Here's my script... | It changes player's face.
local function changeFace(face) -- local because upon this there is a player added function. player.Character.Head.face.Texture = face end
player.Chatted:connect(function(message)
for i = 1, #Faces do
if message == #Faces[i] then
changeFace(#Faces[i])
end
end
end)
end)
How do I fix this thing? I am new to tables and for loops, So please help me.
Thankyou.

1 comment
You should look up String Manipulation in Roblox Wiki. I'd help but I myself need to study that more before I give information that could be wrong!