I want to make it so a sound plays when you say something in chat, how would I do that?
This Script Is Server Sided Meaning That It Will Work For Every Client In Game Not Just For The Local Client:
01 | game.Players.PlayerAdded:Connect( function (plr) -- Player Added Event |
02 | plr.Chatted:Connect( function (msg) -- Chatted Event |
03 | local sound = Instance.new( "Sound" ) -- Make New Sound |
04 | sound.Parent = workspace -- Parent Of The Sound |
05 | sound.SoundId = "" -- Sound Id Make Sure To Put rbxassetid:// Or It Won't Work! |
06 | sound.Name = "IDK" -- Sound Name |
07 | sound:Play() -- Play The Sound |
08 | wait(sound.TimeLength) -- Wait Until The Song Finished |
09 | sound:Stop() -- Stop It Playing |
10 | sound:remove() -- Remove It |
11 | end ) -- End The Function |
12 | end ) -- End The Function |
I Hope I Was More Clear Here Sorry That I Didn't Explain That Well I Was On My Phone.
01 | game.Players.PlayerAdded:Connect( function (plr) |
02 | plr.Chatted:Connect( function (msg) |
03 | local sound = Instance.new( "Sound" ) |
04 | sound.Parent = workspace |
05 | sound.SoundId = "" -- Sound Id |
06 | sound.Name = "IDK" -- Sound Name |
07 | sound:Play() |
08 | wait(sound.TimeLength) |
09 | sound:Stop() |
10 | sound:Destroy() |
11 | end ) |
12 | end ) |
That is the serverscript