Hello everyone! Today i will show you how to play a sound when you type a set word, so let’s begin!
So first make a folder in ServerScriptService and name it “Chat Sounds”, then insert a script. Now type this in the script:
game.Players.PlayerAdded:Connect(function(player)
player.Chatted:Connect(function(msg)
end)
end)
Now we need to set the word, it can be anything you want. For this tutorial, i’ll be using Bruh.
So add that to the script:
game.Players.PlayerAdded:Connect(function(player)
player.Chatted:Connect(function(msg)
if msg == "bruh" then
end)
end)
Alright, so we now need a sound. You can either create one or get one from the audio section of the toolbox. I’m not gonna show how to make a sound, but there are tutorials for making sounds.
So let’s say you got/created a sound, you wanna copy it’s id. Now insert a sound in Workspace (You can name the sound what you want, but i won’t rename it for this tutorial) and go to the Properties tab, select soundId and paste the id. Now let’s go back to the script.
Now we want to make the sound play when a player has said that word, so you need to add:
game.Players.PlayerAdded:Connect(function(player)
player.Chatted:Connect(function(msg)
if msg == "bruh" then
workspace.Sound:Play()
end
end)
end)
And we are done, you can test your game and type the word you set in line 3 (the if then statement) and it should play the sound.
Thanks for reading and bye!!