I currently have a working script that allows an animation to be run once each click. During these clicks, I want a sound to play that only the player can hear (I assume local Sound). I am unsure as to where/how to incorporate the sound playing when the animation is running/on click.
local debounce = false
script.Parent.Equipped:Connect(function(Mouse)
Mouse.Button1Down:Connect(function()
if not debounce then
debounce = true
animation = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(script.Parent.Animation)
animation:Play()
animation.Stopped:Wait()
debounce = false
end
end)
end)
If you mean sounds playing when a animation reaches a certain keyframe,
markers are very useful for that.
You have to manually add these markers when you make the animation, but once that is done it is fairly easy to tie a sound effect to it.
Simply use this function, which will return a Roblox signal object, connect it using :Connect(function) and play your sound effect inside that function.
This event should literally fire every time said marker/point is reached, if you place the marker at the very beginning of your animation it should play the sound right when the animation starts, stuff like this is also very useful if you want things such as footstep sounds to be synchronized with your walking animation.