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
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)