How do I sync sounds with animations

Hey, I’ve been working on this FPS framework and since I’ve gotten to the stage of animating the viewmodels, I must add sound. I’ve looked everywhere on the devforum and I don’t see a perfect solution to solving my problem.

I want to sync sounds to animation keyframes and I don’t know where to start.

Here is a shooting & reloading clip
https://gyazo.com/6943095f990ab884be522163ecd2c969

I’m only interested in syncing sounds for the reloading animation.

4 Likes

Play the audio when the player has pressed a certain button.

I want to add sounds on each individual keyframe. I could time the sounds but that’s too much work.

GetMarkerReachedSignal

you can right click on a keyframe to add an animation event/signal with a name and a parameter
ifqjiwfijqwfji

from there hook the animation to a marker signal

	animation:GetMarkerReachedSignal("Audio"):Connect(function(id)
        --"id" is the parameter in the inserted animation marker
		local audio = Instance.new("Sound")
		audio.SoundId = "rbxassetid://"..id
		audio.Parent = self.Character.Head
		audio:Play()

		audio.Ended:Connect(function()
			audio:Destroy()
		end)
	end)

to generate a sound everytime this marker is reached

6 Likes