Playing sounds on /e emotes

Hi,

I’m trying to figure out how to make it so that when an emote would be played, it also plays a sound. I looked at AnimationTrack | Roblox Creator Documentation for any hints, but I can’t seem to understand much about this. I’m not that experienced with scripting.
I could really use a hand here. Some pointers or any hints/basics would be nice.

Thanks,
superhomer64/IsaacBypass.

4 Likes

Gonna bump this, still haven’t found a solution.

if you’re talking about default /e dance commands i believe the script executes it is the chatmodule you can find it here and add an extra line of code that plays a sound, i dont know about the new r15 emotes though

No, I mean:
When I type something like /e flex, it’d play a sound. I’d want something like that. It’s also R6

Just get the chat that has been typed and play the sound based on which chat was typed.

2 Likes

you can check the chat message and play a sound if the chat message is a command

here is a simple example put it in a serverscript:

game.Players.PlayerAdded:Connect(function(plr)
	plr.Chatted:Connect(function(msg)
		if msg == "/e flex" then
    		print("sound plays here")
    	end
	end)
end)
2 Likes

Would this be a sound that’s emitted on the player, and not serverwide?

do you want the sound to only play for the client?

Sorry, let me elaborate (it’s 1 in the morning for me):

I want to try to make an emote that emits sounds, like how Fistitown does it with /e taunt, somehow. I wanna try to make it so it plays a sound every time you do the emote.

I’m really tired, so please bear in mind with me. :woozy_face:

1 Like

the script I just sent here should work if I understood it correctly :sweat_smile:
basically, it checks for every message and creates and plays a sound if the message is the command you’re looking for. here are both versions

If you want it so everyone can hear it, put this in a Server Script in ServerScriptService.

--//Server Side (Everyone can hear)
game.Players.PlayerAdded:Connect(function(plr)
	local char = plr.Character or plr.CharacterAdded:Wait()
	plr.Chatted:Connect(function(msg)
		if msg == "/e flex" then
			local sound = Instance.new("Sound")
			sound.SoundId = "rbxassetid://soundid"
			sound.RollOffMaxDistance = 100 --optional
			sound.Parent = char
			sound:Play()
            game.Debris:AddItem(sound, 10)
		end
	end)
end)()

or if you want it so only the player who said the command can hear it, put this in a local script in StarterCharacterScripts or StarterGui.

--//Client Side (Only plays for the player)
local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
plr.Chatted:Connect(function(msg)
	if msg == "/e flex" then
		local sound = Instance.new("Sound")
		sound.SoundId = "rbxassetid://soundid"
		sound.Parent = char
		sound:Play()
        game.Debris:AddItem(sound, 10)
	end
end)
6 Likes

How can I do this but instead make the sound play from the character when a certain id is played? Because I have an animation that requires the key “P” to be pressed.

1 Like

Not sure if this will answer your question, but I give it a try.
LocalScript inside StarterPlayerScript.

local UserInputService = game:GetService("UserInputService")
local Players = game:GetService("Players")

local Player = Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()

local Debounce = true

UserInputService.InputBegan:Connect(function(Key, Typing)
	if Typing then return end
	
	if Key.KeyCode == Enum.KeyCode.P and Debounce then
		Debounce = false
		local Animation = Instance.new("Animation")
		Animation.Parent = Character
		Animation.AnimationId = "rbxassetid://8871086332" -- Example
		
		local Sound = Instance.new("Sound")
		Sound.Parent = Character
		Sound.SoundId = "rbxassetid://1839040522" -- Example
		
		local Humanoid = Character:WaitForChild("Humanoid")		
		Humanoid:LoadAnimation(Animation)
		Sound:Play()
		task.wait(5)
		Debounce = true
	end
end)

it would be helpful to lower the message.

	plr.Chatted:Connect(function(rawmsg)
        local msg = rawmsg:lower()
		if msg == "/e flex" then
    		print("sound plays here")
    	end
	end)
end)

This only plays the sound, the animation does not play. and there is no way to set the volume of the sound, I also want the player to emit the sound. This is the script I have from youtube.

local keyPressed = Enum.KeyCode.P --Another example Enum.KeyCode.N
local animationId = “8999377853” --Change to your animation Id

local userInputService = game:GetService(“UserInputService”)
local player = game:GetService(“Players”).LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild(“Humanoid”)
local animation = Instance.new(“Animation”)
animation.AnimationId = “rbxassetid://”…animationId
local animationTrack = humanoid:LoadAnimation(animation)

userInputService.InputBegan:Connect(function(input,isTyping)
if isTyping then return end
if input.KeyCode == keyPressed then
if not animationTrack.IsPlaying then
animationTrack:Play()
else
animationTrack:Stop()
end
end
end)

1 Like

Welp, you found out the solution.
good job mate!

That’s not the solution, that only plays the animation, I’m looking to play sound with the emote as I mentioned earlier, I’ll continue looking.

1 Like

Playing sound in server-side or client-side?

Server side, I want everyone to hear it.

1 Like

LocalScript in StarterPlayerScript

local UserInputService = game:GetService("UserInputService")

local RemoteEvent = game.ReplicatedStorage:WaitForChild("RemoteEvent")

local Debounce = true

UserInputService.InputBegan:Connect(function(Key, Typing)
	if Typing then return end
	
	if Key.KeyCode == Enum.KeyCode.P and Debounce then
		Debounce = false
		RemoteEvent:FireServer()
		task.wait(35)
		Debounce = true
	end
end)

ServerScript in ServerScriptService

local Debris = game:GetService("Debris")

local RemoteEvent = game.ReplicatedStorage:WaitForChild("RemoteEvent")

local Sound = game.ReplicatedStorage:WaitForChild("Sound")

RemoteEvent.OnServerEvent:Connect(function(Player)
	local playerToTarget = game.Workspace:FindFirstChild(Player)
	local character = Player.Character
	
	local soundClone = Sound:Clone()
	soundClone.Parent = character
	soundClone:Play()
	soundClone.Name = ("Sound from " .. Player.Name)
	
	Debris:AddItem(soundClone, 35)
end)

If this doesn’t work DM me.

What is this and where do I put it? This will play sound from the character, loop, and stop when P is pressed again?

1 Like