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.
function Say(fullmsg) lowermsg=string.lower(fullmsg) msg=string.gsub(lowermsg,"ing","A")-- A will play the ing sound msg=string.gsub(msg,"ch","B") -- B will play the ch sound local msg=string.gsub(msg,"wh","C") -- C will play the wh sound Amount = string.len(msg) Number=1 repeat Number=Number+1 cap(string.sub(msg,Number)) -- I think my problem is here until Number==Amount 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).
-- put this in a local script local player = game.Players.LocalPlayer local A = Instance.new("Sound") A.Parent = game.Workspace A.SoundId = "..." -- make this the id of the sound, and do this for each sound -- list the rest of the sounds here -- player.Chatted:connect(function(fullmsg) -- when the player chats, do this function lowermsg=string.lower(fullmsg) if lowermsg == "ing" then A:Play() end if lowermsg == "ch" then B:Play() end 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