How to make it if we talk , we can hear random sounds

How can we make if we talk , we can hear sounds

Everything is explained here. I would like to have a answer please.
Like how did they made it (Explaining)

Player.Chatted:Connect(function(message: string)
   -- 'message' is what was sent to the chat
   Sound:Play() -- Play whatever random sound was chosen
end)

https://developer.roblox.com/en-us/api-reference/event/Player/Chatted
https://developer.roblox.com/en-us/api-reference/function/Sound/Play
https://developer.roblox.com/en-us/api-reference/datatype/Random

1 Like

Quite simple,

You can use player.Chatted event to detect when players say something on chat,
and then simply play a random sound from your Audio folder.

Lets assume you have a folder of sounds in ReplicatedStorage:
image

All you have to do is -

local Replicated = game:GetService("ReplicatedStorage")

Player.Chatted:Connect(function(message: string)
   local randomMusic =  Replicated.Sounds:GetChildren()[math.random(1,# Replicated.Sounds:GetChildren())
   randomMusic:Play()
end)

It’s just random tho. Like not the message they choose. But random messages. It’s also choosing random sounds

This will choose a random sound out of our Sounds folder in ReplicatedStorage.

1 Like

You forgot to mention who is"player" in the script. It’s giving a error.

Where do you place the script by the way.