Why isn't this working?

Hello! So I am trying to make it so when a player talks in chat an audio will play. The script seems like it should work, I’m just not sure why.

Local script (inside of StarterGui):

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

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

Script (inside of ServerscriptService):

local event = game.ReplicatedStorage.ChatSFXEvent

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

You can try adding print statements. For example, you can add a print statement before and after the event:FireServer() line to make sure that the client is properly firing the event, and you can add a print statement inside the OnServerEvent function to verify that the server is properly receiving the event.

I did try adding print statements previously. It seems like a problem in the local script. I’m just not sure what to do.

Try adding the SFX inside SoundService.

That is not the problem. The remote event isn’t firing.

Why don’t you check if the player chatted on the server?

An example would be

game.Players.PlayerAdded:Connect(function(plr)
plr.Chatted:Connect(function()
-- Let your SFX Play
end)
end)
1 Like

Both of your scripts look correct, all I can think of is that you didn’t properly enable the local script, if it is you can try checking if the ChatSFX sound exists in the Workspace and that it’s properly set up.

Why do you have to split them just put your task in the .chatted function

He said server… Please read all messages before responding.

1 Like

Server-Script

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.