How to make a audio play when someone talks?

(let me know if this is the wrong category)

Hi, so I was wondering on how I can make it when a player talks that an audio will play. I don’t have a script. I am just wondering how I can do it. If you know how, please let me know, thanks.

1 Like

A way to do this is in startergui. You can get local player from local script and do plr.chatted

Kind of like how I coded my cloak system

local plr = game.Players.LocalPlayer
local groupId = 12962475
local minRank = 50
local repStore = game:GetService("ReplicatedStorage")
local cloakEvent = repStore:FindFirstChild("CloakEvent")
local value = script.isOn

plr.Chatted:Connect(function(msg)

	string.lower(msg)

	if msg == "!cloak" and plr:GetRankInGroup(groupId)>=minRank then
		cloakEvent:FireServer("Cloak")
	end
end)	 ```

You can replace the event with your sound play. You can put your audio in sound service
1 Like

But is there a way so that everyone else in the server hears it too? I would use a remote event right?

I made a local script and put it inside of StarterGui, and I made a script inside of SeverScriptService. I’m trying to make it so everyone in the server hears it.

Local Script:

local plr = game.Players.LocalPlayer
local event = game.ReplicatedStorage.ChatSFXEvent

plr.Chatted:Connect(function()
	event:FireServer()
end)

Script:

local event = game.ReplicatedStorage.ChatSFXEvent

event.OnServerEvent:Connect(function(plr)
	game.Workspace.ChatSFX:Play()
end)

Is it working? or not because im pretty sure thats correct

It doesn’t work. And no error is coming in the output either.

Print in some of the functions to make it goes through the functions

I’m pretty sure it is the local script. It isn’t printing. And I just tried putting print in the regular script, it doesn’t print anything either.