So Im making a Say command that will let you add an AI Voice. Im having trouble with this part of the script.
CAP stands for Check And Play The cap function will check the Letter and match it with the corresponding sound, then play the sound.
01 | function Say(fullmsg) |
02 | lowermsg = string.lower(fullmsg) |
03 | msg = string.gsub(lowermsg, "ing" , "A" ) -- A will play the ing sound |
04 | msg = string.gsub(msg, "ch" , "B" ) -- B will play the ch sound |
05 | local msg = string.gsub(msg, "wh" , "C" ) -- C will play the wh sound |
06 | Amount = string.len(msg) |
07 | Number = 1 |
08 | repeat |
09 | Number = Number+ 1 |
10 | cap(string.sub(msg,Number)) -- I think my problem is here |
11 | until |
12 | Number = = Amount |
13 | end |
I have a feeling the problem is the function calls more than one letter. Can someone help me? Just ask me in chat with "@fancyboby47" if you need further explanations!
Thank you!
Remember, that when the function is being called, you are asking if that "fullmsg" is being messaged. (Also don't forget that iterating your code is more organized).
01 | -- put this in a local script |
02 |
03 | local player = game.Players.LocalPlayer |
04 | local A = Instance.new( "Sound" ) |
05 | A.Parent = game.Workspace |
06 | A.SoundId = "..." -- make this the id of the sound, and do this for each sound |
07 | -- list the rest of the sounds here -- |
08 |
09 |
10 | player.Chatted:connect( function (fullmsg) -- when the player chats, do this function |
11 | lowermsg = string.lower(fullmsg) |
12 |
13 | if lowermsg = = "ing" then |
14 | A:Play() |
15 | end |
16 | if lowermsg = = "ch" then |
17 | B:Play() |
18 | end |
19 | end ) |
I hope this helps. I'm not quite sure what you are trying to do with the "cap(string.sub(msg,Number))" though...
~N