Speaker Module: For All You NPC Speaking Needs!

![Speaker Module Image](upload://khGr70iQwbw1AZk5vuuxxLmvDJH.png "Speaker Module Image")
Speaker Module
Download

Hi Roblox Community!

I have just released a new module called Speaker Module! Speaker Module lets you easily create NPCs that can talk to players on-screen and in their chat! Here is a quick video of it being used to say an example:

As you can see in the example, the speaker Bob says 2 messages to me (LoveTheBears101), and both appear in the chat. Here is the code I used to make that:

-- Import the module
local speak = require(script.Parent.SpeakerModule)
-- Create a new speaker
speaker = speak.defineSpeaker("Bob", Color3.fromRGB(32, 255, 144), "Gotham", "scale", true, true)
--Wait 4 seconds
wait(4)
-- Speak some text
speaker:speak("Something important... blah blah blah! More Text. Why? Goodbye!", "LoveTheBears101")
-- Wait
speaker:waitUntilFinishedSpeaking()
-- Speak some more text
speaker:speak("This comes second!", "LoveTheBears101")


These are all the functions:
Don’t forget to require the module first!

.defineSpeaker

module.defineSpeaker(Name, ChatColor, ChatFont, ChatTextsize, InChat, NPCLabel)

Arguments
Name - The name of the speaker (String)
ChatColor - The color the person chats in (Color3)
ChatFont - The font the person speaks in (String)
ChatTextSize - The size of the text. Can also be “scale”, which will scale the text according to the screen size (Int or String)
InChat - Whether or not everything the player says goes into the chat (bool)
NPCLabel - Whether or not the person has a (NPC) next to them in the chat (bool)

Returns
Speaker Object - The speaker that you just defined.

:speak

speaker:speak(message, player)

Arguments
message - The message that the speaker says (String)
player - Either the player or player’s name that you want it to speak to (String or Player Instance)

Returns
nil

Note: This function will not wait until the speaker has finished speaking to return.

:waitUntilFinishedSpeaking

speaker:waitUntilFinishedSpeaking()

Waits until the speaker is done talking. It takes no parameters and returns nothing. You can also check if the speaker is speaking using speaker.speaking (bool)


Those are all the functions to create a speaker and make them talk to a player!

If you want to make your speaker talk to everyone, you can do something like this:

for _, player in pairs(game.Players:GetChildren()) do
     speaker:speak("Your message", player)
end

Any questions? Comments? Concerns? Requests? Put them in the replies!!

Get the module here: https://www.roblox.com/library/5805526978

Quick Survey


Please help me make it better by answering these questions

How useful do you think this module will be to you?

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10

0 voters

What best describes your feelings about it?

  • I like it, and I think I’ll use it for development
  • I like it, but I don’t think I’ll use it for development
  • I don’t like it (Please explain)

0 voters


Hope you enjoy!

18 Likes

Wow, this is a really good plugin! Might use this in a Story game after like 3-4 years. Keep up the good work!

1 Like

Thanks!

BTW, it’s a module, not a plug-in :smile:

2 Likes

why can’t the :speak stop the main thread it would be better than calling another function to wait until its finished.

1 Like

What do you mean? Like doing : speak would stop all other speech? Or do you mean when you do :speak it adds it to a quene for it to say?

No if you learn about thread’s in scripts it basically yields it - stops all code around it until it has returned something or finishes a task. This way you don’t have to remember to call a function to wait for it to finish!

Oh, I made it so it runs in a coroutine so you can loop through all the players, and they will all get it at the same time.

I might add a feature to make it run without a coroutine too.

New Update!


Chat now scroll from left to right, making it smoother!
Also, the NPC tag now looks more like normal chat tags!