I’ve been making a script for fun and might release it as a freemodel for everyone to use eventually, have been trying to get it so chat messages get recognized as an audio-based emote and it does work; however, I’m unable to figure out how to make it so that chat messages within a table can be recognized as a valid input even if some of the letters/keys are lowercase or not (e.g., chatting “nOO!” instead of “Noo!” because of having caps lock on). I’ve been familiar with string.lower in code for awhile now but I haven’t really gotten to using it in scripts that I’ve made in the past but I’m guessing it’s the solution to my problem (basically I wouldn’t know how to even implement string.lower into my code which is why a code example would be nice).
My code:
local FRIGHTENED_MESSAGE = {
["DX"] = true; ["NO!"] = true; -- when you want to have players have a scared response vocalized to more than just these 2 chat texts,
}; -- just copy paste [""] = true; with whatever chat text you want to vocalize inside the quotations
local FRIGHTENED_SOUND = "5282634561" -- post id of scared response audio here inside the quotations
-- DO NOT EDIT ANYTHING PAST UNLESS YOU KNOW WHAT YOUR DOING --
game.Players.PlayerAdded:Connect(function(Player)
Player.Chatted:Connect(function(msg)
local input = (msg);
if FRIGHTENED_MESSAGE[input] and Player.Character ~= nil then
if Player.Character:FindFirstChild("Vocalizer") == nil then -- checks if a sound for a player hasn't been created yet
print("Chat event triggered for "..Player.Character.Name)
local sound = Instance.new("Sound", Player.Character) -- create sound having avatar as the origin point
sound.Name = "Vocalizer"
sound.SoundId = ("rbxassetid://"..FRIGHTENED_SOUND)
sound:Play()
wait(6.5)
sound:Destroy()
else if Player.Character:FindFirstChild("Vocalizer") ~= nil then -- if sound exists, wait till it finishes
print("Slow your horses! You haven't finished saying something yet!")
else
warn("Something unexpected happened!")
end
end
end
if Player.Character == nil then
error("Player does not exist in the workspace!")
end
end)
end)
How exactly do I solve this?