I’m making a new game, and I would like to include a NPC chatting sound for when they say something (from a dialog)
Sadly, I can only find an event for when the player chooses a dialog option
I might be able to “recreate” the event by tracking clicks and checking if the dialog is enabled, but I would much rather just have some sort of event for when a chat bubble appears.
You could do it a few ways. One option is to check the NPC text for special characters and play a sound when one appears. You could use different sounds for different text characters. Another option is to time a sound to play during a specific dialog.
I think what you are looking for is the “InUse” property. When it is enabled, it is being used by at least one player.
What you can do is something like this:
local Dialog = script.Parent -- Wherever your dialog is.
Dialog:GetPropertyChangedSignal("InUse"):Connect(function()
if Dialog.InUse == true then
-- This is just an example that assumes the dialog's parent is the head.
-- Change this with whatever functionality you want.
print("You are talking to the NPC called: " .. Dialog.Parent.Parent.Name)
end
end)
This is a server Script in the Dialog instance. I don’t recommend doing it like this for every dialog, I think it looks cleaner when you have one script in the ServerScriptService and just use CollectionService’s GetTagged method to get an array of the Dialogs you tagged.
For a LocalScript implementation, I saw this:
You can use this to check if the GetCurrentPlayers method returns an array that has the LocalPlayer in it.
i also need to play the sound after a response is given
so the amount of time between giving a response and the npc saying another piece of dialogue isnt static, then i basically have to code my own dialogue system or just not play sound