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

How do I get a sound to play so everyone can hear?

Hi, I recently asked a question and it was solved here's the question if you want to see:

http://scriptinghelpers.org/questions/124584/animation-not-sure-how-to-add-sound-to-an-animation-any-suggestions

But I'm having a new issue where the sound can only be heard by the player. I still want the sound to be able to be played during an animation and have it so people around the player can hear it. Any help I can get is appreciated.

Here's the script so far:

wait(.5)

Player = game.Players.LocalPlayer.Character
animation1 = Player.Humanoid:LoadAnimation(script.Animation1)
animation2 = Player.Humanoid:LoadAnimation(script.Animation2)
animation3 = Player.Humanoid:LoadAnimation(script.Animation3)
CanEmote = true

game:GetService('UserInputService').InputBegan:Connect(function(Input, GameProcessed)
	if not GameProcessed and Input.KeyCode == Enum.KeyCode.P then
		local emote = math.random(1,3)
		if emote == 1 and CanEmote == true then
			Player:WaitForChild('Humanoid').JumpPower = 0
			Player:WaitForChild('Humanoid').WalkSpeed = 0
			script.Sound1:Play()
			animation1:Play()
			CanEmote=false
			wait(1)
			Player:WaitForChild('Humanoid').JumpPower = 50
			Player:WaitForChild('Humanoid').WalkSpeed = 16
			CanEmote=true

		elseif emote == 2 and CanEmote == true then
			Player:WaitForChild('Humanoid').JumpPower = 0
			Player:WaitForChild('Humanoid').WalkSpeed = 0
			script.Sound2:Play()
			animation2:Play()
			CanEmote=false
			wait(1)
			Player:WaitForChild('Humanoid').JumpPower = 50
			Player:WaitForChild('Humanoid').WalkSpeed = 16
			CanEmote=true

		elseif emote == 3 and CanEmote == true then 
			Player:WaitForChild('Humanoid').JumpPower = 0
			Player:WaitForChild('Humanoid').WalkSpeed = 0
			script.Sound3:Play()
			animation3:Play()
			CanEmote=false
			wait(1.5)
			Player:WaitForChild('Humanoid').JumpPower = 50
			Player:WaitForChild('Humanoid').WalkSpeed = 16
			CanEmote=true
		end
	end
end)

1 answer

make a server script and parent it to that script's parent, basically the same location as the current script you're using and then paste this script inside the server script

wait(.5)

Player = game.Players.LocalPlayer.Character
animation1 = Player.Humanoid:LoadAnimation(script.Animation1)
animation2 = Player.Humanoid:LoadAnimation(script.Animation2)
animation3 = Player.Humanoid:LoadAnimation(script.Animation3)
CanEmote = true

game:GetService('UserInputService').InputBegan:Connect(function(Input, GameProcessed)
    if not GameProcessed and Input.KeyCode == Enum.KeyCode.P then
        local emote = math.random(1,3)
        if emote == 1 and CanEmote == true then
            Player:WaitForChild('Humanoid').JumpPower = 0
            Player:WaitForChild('Humanoid').WalkSpeed = 0
            script.Sound1:Play()
            animation1:Play()
            CanEmote=false
            wait(1)
            Player:WaitForChild('Humanoid').JumpPower = 50
            Player:WaitForChild('Humanoid').WalkSpeed = 16
            CanEmote=true

        elseif emote == 2 and CanEmote == true then
            Player:WaitForChild('Humanoid').JumpPower = 0
            Player:WaitForChild('Humanoid').WalkSpeed = 0
            script.Sound2:Play()
            animation2:Play()
            CanEmote=false
            wait(1)
            Player:WaitForChild('Humanoid').JumpPower = 50
            Player:WaitForChild('Humanoid').WalkSpeed = 16
            CanEmote=true

        elseif emote == 3 and CanEmote == true then 
            Player:WaitForChild('Humanoid').JumpPower = 0
            Player:WaitForChild('Humanoid').WalkSpeed = 0
            script.Sound3:Play()
            animation3:Play()
            CanEmote=false
            wait(1.5)
            Player:WaitForChild('Humanoid').JumpPower = 50
            Player:WaitForChild('Humanoid').WalkSpeed = 16
            CanEmote=true
        end
    end
end)

3 comments

0

I'm trying to get it so it can't be heard from people far away, only the people who are close by the animation. Basically I want the sound to play from the character's head.

0

That is called sound region. Perhaps watch this video: https://www.youtube.com/watch?v=L_Jga2MgRdU

0

Can I use the sound regions while moving? Basically this script is like a taunt for a game

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