Help me with my CHAT script

Hello, I would like you to help me please for a script, in fact what I want to do is that when a person says a word in the roblox chat let’s imagine, like “hi”, I would like my character on roblox to answer it automatically.

example: Person1 says “hi”.

Me : I say hi". automatically without having to type “hi” on my keyboard. I tried something but I can’t, I would like to make a local script

game.Players.PlayerAdded:Connect(function(player)
    player.CharacterAdded:Connect(function(character)
        if Message == "hi" then
1 Like

Try

game.Players.PlayerAdded:Connect(function(player)
    player.Chatted:Connect(function(message)
        print(message)
    end)
end)
1 Like

Thank you, this helps me but I have another small question, do you know how to make when a person says “hi” I answer them?

1 Like

You could have an if-else chain checking if the message is any one of a set of known messages. Or have a dictionary mapping known messages to responses. E.g.

local ChatService = game:GetService("Chat")
ChatService.BubbleChatEnabled = true

game.Players.PlayerAdded:Connect(function(player)
    player.Chatted:Connect(function(message)
        if message == "hi" then
            ChatService:Chat(game.Players.LocalPlayer.Character.Head, "hello")
        end
    end)
end)

or

local ChatService = game:GetService("Chat")
ChatService.BubbleChatEnabled = true

local messageResponses = {
    ["hi"] = "hello",
    ["how are you?"] = "I'm well, thanks",
}

game.Players.PlayerAdded:Connect(function(player)
    player.Chatted:Connect(function(message) 
        local response = messageResponses[message]
        if not response then return end
        ChatService:Chat(game.Players.LocalPlayer.Character.Head, response)
    end)
end)
1 Like

Thanks you very much for help me.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.