Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Help of how I play a sound when animation plays?

Asked by 7 years ago

Please encode Lua code in the Lua block code tag (look for the Lua icon in the editor).

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)

0
Sorry... I don't know why it didn't make my script into a code block wolfbarrier123 -25 — 7y
0
Really simple. Just play a sound after you play the animation. RubenKan 3615 — 7y
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 Goulstem 8144 — 7y

1 answer

Log in to vote
0
Answered by
soutpansa 120
7 years ago

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()
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? wolfbarrier123 -25 — 7y
0
Nvm. What is the script to stop? a:stop() ? wolfbarrier123 -25 — 7y
1
WAIT. Nevermind. Thanks! This script worked! You're a life save wolfbarrier123 -25 — 7y
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 soutpansa 120 — 7y
Ad

Answer this question