(Beginner) Need help making different chat inputs have the same result

I’m trying to implement a system where a player can speak to a part through the bubble chat. I’ve found something online that could help with this, but it seems to only be for one chat input. (For example, if they say hi, the part will reply, and that’s the only interaction.) However, what I was is for the player to be able to say a variety of things, such as hello, hi, greetings, etc., and the part will have the same reply for all the greetings.

I’ve tried researching tables/converting strings to tables, but I haven’t really found anything that would help my situation. Thanks in advance! :slight_smile:

1 Like

Ah yes, going to the old OOOOOLD legacy stuff

There’s actually a more simpler way to do this :open_mouth: We could just assign our greetings of what we want to say inside the Table, check when a Player starts to Chat, check its Message, then use the Chat service to make the Part chat I believe

--This should be a Server Script in ServerScriptService
local TalkingPart = workspace.Part
local Greetings = {"hello", "hi", "greetings"}
local ChatService = game:GetService("Chat")

        local IgnoreCaps = string.lower(Message)
        if table.find(Greetings, IgnoreCaps) then
            ChatService:Chat(TalkingPart, IgnoreCaps)

We’d want to keep our strings lowercase in this instance, if by any means the Player wants to use punctuation for greeting the part

I believe this should work though?

Hey man, thanks for the quick reply! I tried this out, and it almost worked. Where you wrote:

ChatService:Chat(TalkingPart, IgnoreCaps)

I got an output stating “unable to cast string to token”. I messed around alittle bit and managed to get it to work by removing the “IgnoreCaps”, and replacing it with the part’s response and a color. Now it says:

ChatService:Chat(talkpart, “Greetings”, “Blue”)

Now, seeing as I’m a beginner, was this the right call? Or should I have left the IgnoreCaps? Something that I should mention is that during the test, the script wouldn’t pick up what I was saying if I used punctuation, like commas or periods. Again, thanks so much for your help! :grin:

Okay this is Outdated >:(

You almost had it I believe, since the third parameter requires a ChatColor you could try doing this?

ChatService:Chat(talkpart, "Greetings", Enum.ChatColor.Blue)

Alright awesome, I’ll try this out now. I’m alittle confused on where I should include the message that I want the talkpart to reply with, though?

Ooooh wait I’m dumb

Yeah what you had was fine, that should work since you do want the Part to reply back with the same output every time

LOL no worries man, I appreciate all the help.

1 Like