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.
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
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.
the script I just sent here should work if I understood it correctly
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)
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.
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)
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)
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)