Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Trying to make a script to where it plays a sound when chatted, can anyone help?

local SoundID = "rbxassetid://2469886818" 
local PlayerHead = script.Parent.Parent.Character:FindFirstChild("Head")
local sound = Instance.new("Sound")
sound.Parent = PlayerHead
sound.SoundId = SoundID

This is the beginning where it creates the sound in the head, I need help with making it to where the audio plays on character chatted. (This is located in StarterPack)

1 comment

0

Why in StarterPack and not StarterPlayer?

1 answer

✓ Accepted answer

Put A Remote Event In Replicated Storage And Call It SoundEvent

Then Put A Local Script In The Starter Gui

Put This Is The Local Script:

game.ReplicatedStorage.SoundEvent.OnClientEvent:Connect(function()
local SoundID = "rbxassetid://2469886818" 
local PlayerHead = game.Players.LocalPlayer.Character:FindFirstChild("Head")
local sound = Instance.new("Sound")
sound.Parent = PlayerHead
sound.SoundId = SoundID
sound:Play() -- Edit: Sorry Forgot This
wait(sound.Duration)
sound:remove()
end)

Now Put This In A Script Located In Server Script Service:

game.Players.PlayerAdded:Connect(function(plr)
plr.Chatted:Connect(function(msg)
game.ReplicatedStorage.SoundEvent:FireClient(plr)
end)
end)

Still Need Help? Contact Me Below:

Discord: Harry_TheKing1#0975

Twitter: @harry_theking1

Or Simply Just Reply On This Awnser!

4 comments

0

I followed all of the steps and it didnt seem to have any audio

0

Sorry i Forgot To Play The Sound

0

so this works, but only the player that chatted can hear it

0

Ah If You Want It To Play For Everyone Then You Will Have To Re Script It

This discussion is preserved as it was. New answers, comments, and votes are closed.