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

Help of how I play a sound when animation plays?

I have an animation that plays when I hold it. (Eating Animation)

And basically I just want to know how to add a "Sound" to it when the animation plays. So like a sipping sound when they drink. Here's the animation: Below

GelatoCup = script.Parent player = game.Players.LocalPlayer.Character Humanoid = player.Humanoid

GelatoCup.Equipped:connect(function(mouse) mouse.Button1Down:connect(function() local animation = Instance.new("Animation") animation.Parent = player animation.AnimationId = "http://www.roblox.com/Asset?ID=633296568" local animTrack = Humanoid:LoadAnimation(animation) animTrack:Play() end) end)

3 comments

0

Sorry... I don't know why it didn't make my script into a code block

0

Really simple. Just play a sound after you play the animation.

1

Please put your code in code block. It makes it infinitely easier for us to help you. If you don't know how, then highlight your code and select the icon furthest to the right: http://prntscr.com/e7iown

1 answer

✓ Accepted answer

Well. I can show you how I play sounds in my scripts. I'm guessing that GelatoCup is a tool, right? I'd insert a sound into gelatin cup, right after the animation, put this:

 local a = Instance.new("Sound")
           a.SoundId = "http://www.roblox.com/asset/?id=PUTSOUNDIDHERE" -- put the sound id at the end of the URL
           a.Parent = x -- assuming that x is the GelatoCup, you can change x to whatever you want
           a.Volume = 2 -- what ever volume you want
           a:play()

4 comments

0

Will this make it play when I click it the same time the animation play? Then it won't play the sound when I unequip it?

0

Nvm. What is the script to stop? a:stop() ?

1

WAIT. Nevermind. Thanks! This script worked! You're a life save

0

oh sorry. I forgot about this question, my bad :P. You only need to use stop() when the sound is looped, so if it was a.Looped = true, then you could add a wait() then a:stop(). Or something like that. Also, I have to mention that you need to put the code I sent you in the same function as the MouseDown Function, or make another function for it. Sorry about that again, but I'm glad that it worked

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