Chat sound Problem

local Players = game:GetService(“Players”)
local SoundService = game:GetService(“SoundService”)

local function playChatSoundForLetter(player, message)
local character = player.Character
if character then
local head = character:FindFirstChild(“Head”)
if head then
for i = 1, #message do
local randomPitch = math.random(9,10)
local letter = message:sub(i, i)
local sound = Instance.new(“Sound”)
sound.Parent = head
sound.SoundId = “rbxassetid://13664620552”
sound.Volume = 1
sound.RollOffMaxDistance = 50
sound:Play()
sound.PlaybackSpeed = (randomPitch / 10)
head.Face.Texture = “rbxassetid://14774529510”
wait(0.1)
head.Face.Texture = “rbxassetid://14747411629”
sound:Destroy()
end
end
end
end

Players.PlayerAdded:Connect(function(player)
player.Chatted:Connect(function(message)
playChatSoundForLetter(player, message)
end)
end)

the script works great but when there is a chat timeout
image
and if u chat again it still plays the sound… how do i make it so if its on timeout the sound cant play?

I’m pretty sure there is a remote event that fires when the user successfully sends a message, maybe you can experiment with that?

Try using one of TextChatService’s events. Can’t tell which cause I never used them before.

ah i see there is a thing for message received ill test it out

so i tried this out

Players.PlayerAdded:Connect(function(player)
textchatService.MessageReceived:Connect(function(message)
playChatSoundForLetter(player, message)
end)
end)

and it doesnt seem to work why?

i ended up fixing it… somehow… heres a local script

local textchatservice = game:GetService(“TextChatService”)

local chatEvent = game.ReplicatedStorage.ChatEvent

textchatservice.MessageReceived:Connect(function(message)
print("Client sending message: " … tostring(message)) – Convert message to string
chatEvent:FireServer(message)
end)

heres the server script

local Players = game:GetService(“Players”)
local textchatService = game:GetService(“TextChatService”)

local chatEvent = game.ReplicatedStorage.ChatEvent

local function playChatSoundForLetter(player, message)
local character = player.Character
if character then
local head = character:FindFirstChild(“Head”)
if head then
for i = 1, #tostring(message) do
local randomPitch = math.random(9, 10)
local letter = tostring(message):sub(i, i)
local sound = Instance.new(“Sound”)
sound.Parent = head
sound.SoundId = “rbxassetid://13664620552”
sound.Volume = 1
sound.RollOffMaxDistance = 50
sound:Play()
sound.PlaybackSpeed = (randomPitch / 10)
head.Face.Texture = “rbxassetid://14774529510”
wait(0.1)
head.Face.Texture = “rbxassetid://14747411629”
sound:Destroy()
end
end
end
end

game.Players.PlayerAdded:Connect(function(player)
chatEvent.OnServerEvent:Connect(function(player,message)
print("Server received message: " … tostring(message)) – Debugging statement
playChatSoundForLetter(player, message)
end)
end)

obviously there is probably many problems but this has fixed it so far.

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