Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Can someone help me with this string thing?

Asked by
Dr_Doge 100
8 years ago

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!

1 answer

Log in to vote
0
Answered by 8 years ago

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

0
Look, I understand what Chatted and connect are, and I know very well how to use them. The reason I did't use them is because I dont want this function to be just for Chat. Also, your code is far from what Im trying to do. I think what Im trying to do is over your level, so if you dont understand the code, please dont try to correct me. Thanks for the much appreciated effort though. Dr_Doge 100 — 8y
Ad

Answer this question