How to play sound while Animation

Hi, I am trying to make a animation and playing it ingame, the animations work but I am also trying to play a sound while the Animation is playing. I already tried to use AnimationTrack.Length and AnimationTrack.KeyFrameReached. Both didn´t really work, does anyone got some ideas to play sounds while a animation is playing?

Put a boolvalue in repstorage called CheckAnimation

Then do this:

local sound = [yoursoundlocation]
local CheckAnimation = game.ReplicatedStorage.CheckAnimation

–You will need to update the --“CheckAnimation” BoolValue once the --animation is running.

CheckAnimation.Changed:Connect(function()
–now you need to either play the --sound or tween its volume
end)

1 Like

If it’s a local animation then it’d be a little different

1 Like

it isnt really working, did I do it right?

local sound = game.Workspace.EvilPresence
local CheckAnimation = game.ReplicatedStorage.CheckAnimation

wait(1)
CheckAnimation.Value = true
local y = game.Workspace.FINALBOSS_Phase1.Humanoid:LoadAnimation(bosshead.JumpingDown)
y:Play()
CheckAnimation.Changed:Connect(function()
wait(4)
sound:Play()
										
end)

sry I am not very good at scripting

Can you show us your current script?

1 Like

This is a small part of the whole script because I dont really want to show the full script :confused:

wait(3)
						FrameVisible.Value = false
						game.Workspace.InvisibleWallBeforeBossFight:Destroy()
						game.Workspace.TouchBossStage.Touched:Connect(function(hitting)
							
							if hitting.Parent:FindFirstChild("Humanoid") then
								if not debounce2 then

									debounce2 = true
							
									local sound = game.Workspace.EvilPresence
									local CheckAnimation = game.ReplicatedStorage.CheckAnimation
									
										
									
									wait(1)
									CheckAnimation.Value = true
									local y = game.Workspace.FINALBOSS_Phase1.Humanoid:LoadAnimation(bosshead.JumpingDown)
									y:Play()
									CheckAnimation.Changed:Connect(function()
								wait(4)
								sound:Play()
								
								
							y.Stopped:Wait()

end)
local Sound = workspace.EvilPresence --sound path
local Animation = bosshead.JumpingDown --animation path
local Humanoid = workspace.FINALBOSS_Phase1.Humanoid --humanoid path

local AnimationTrack = Humanoid:LoadAnimation(Animation)

--playing animation and sound
AnimationTrack:Play()
Sound:Play()

--waiting for the animation to end
AnimationTrack.Stopped:Wait() --for non-looped animation
--AnimationTrack.DidLoop:Wait() --for looped animation

--stopping the sound
Sound:Stop()
1 Like