Chat Sound System Not Working

I’m trying to make a system where if the player speaks, it plays a sound. 2 very simple scripts, A local script to activate it, and a server script to make it happen server sided.

My problem is that it doesn’t print out any errors, but the sound just doesn’t play. My LocalScript is inside ServerScriptStorage, and my ServerScript is inside my RemoteEvent which is in ReplicatedStorage.

Local Script:

local plrs = game:GetService("Players")
local plr = plrs.LocalPlayer


plrs.PlayerAdded:Connect(function(Plr)
	plr.Chatted:Connect(function(Message)
		local RS = game:GetService("ReplicatedStorage")
		local onChat = RS.OnChat
		
		onChat:FireServer()
	end)
end)

And here is my ServerScript:

local event = script.Parent

event.OnServerEvent:Connect(function(Player)
	local Character = Player.Character
	
	local Sound = Instance.new("Sound", Character:WaitForChild("Torso"))
	Sound.SoundId = "rbxassetid://296126787"
	Sound.Volume = 2
	Sound:Play()
	wait(.5)
	Sound:Destroy()
end)

Anything helps. And yes my sound is on.

1 Like

Try this code.

Local Script:

local plrs = game:GetService("Players")
local plr = plrs.LocalPlayer
local RS = game:GetService("ReplicatedStorage")
local onChat = RS:WaitForChild("OnChat")

plr.Chatted:Connect(function(Message)
onChat:FireServer()
end)

Server Script:

local REP = game:GetService("ReplicatedStorage")
local onChat = REP:WaitForChild("OnChat")

onChat.OnServerEvent:Connect(function(Player)
	local Character = Player.Character
	
	local Sound = Instance.new("Sound", Character:WaitForChild("Torso"))
	Sound.SoundId = "rbxassetid://296126787"
	Sound.Volume = 2
	Sound:Play()
	wait(.5)
	Sound:Destroy()
end)

EDIT: Put “Local Script” inside StarterGui or StarterPlayerScripts and put “Server Script” inside ServerScriptService.

1 Like
local players = game:GetService("Players")

players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(character)
		local hrp = character:WaitForChild("HumanoidRootPart")
		local sound = Instance.new("Sound")
		sound.Parent = hrp
	end)
	
	player.Chatted:Connect(function(message)
		local character = player.Character or player.CharacterAdded:Wait()
		local hrp = character:WaitForChild("HumanoidRootPart")
		local sound = hrp:FindFirstChild("Sound")
		if sound then
			sound.SoundId = "rbxassetid://296126787"
			sound.Volume = 2
			sound:Play()
			sound.Ended:Wait()
			sound:Destroy()
		end
	end)
end)

You don’t need a RemoteEvent instance for this as the “.Chatted” event will fire on the server, don’t forgot the “.PlayerAdded” event does not fire in local scripts (on the client).

Scripts don’t run in Storage locations.

Local script needs to be in StarterPlayer or character
And Server script needs to be in Server script services.

You can also grab the Client in Local script by using

local player = game.Players.LocalPlayer

Thank you so much!

alright now to add more sounds…