Hello. I am trying to make voice chats using the .Chatted event, but for some reason it does work but if I put a period at the end of the word it won’t work. I don’t want to add new strings to the table that is just the same thing but with a period.
local debounce = false
local cChats = {
"help",
"moving foward"
}
local function onPlayerChatted(player, message)
if player.Character:FindFirstChild("Head") and not debounce and player.Team == game.Teams.Marines then
message = string.lower(message)
for i=1,#cChats do
if message:find(cChats[i]) then
local voiceline = script:FindFirstChild(message)
if voiceline then
debounce = true
local vClone = voiceline:Clone()
vClone.Parent = player.Character.Head
vClone:Play()
vClone.Ended:Wait()
vClone:Remove()
debounce = false
end
end
end
end
end
game.Players.PlayerAdded:Connect(function(player)
player.Chatted:Connect(function (message) onPlayerChatted(player, message) end)
end)
I am not that familiar with using string methods. I have tried looking at the strings page but I could barely understand most of it.