How to make weapon swing sounds?

Currently I am following this tutorial and modifying it for my combat system (link will be below). I have a swing sound for each swing animation. How would I have these sounds play during the swings from this tutorial?

Roblox Sword Combat Tutorial Part 1 - YouTube

You can add a sound into the tool, then in a server or local script, you can use this:

local tool = script.Parent --// The parent of the script. Should be the tool
local sound = tool:WaitForChild("Swing") --// Waits for an object named "Swing" to exist, and sets this variable to that object. It should be your swing sound

tool.Activated:Connect(function() --// Runs when the tool gets activated
    sound:Play() --// Plays the sound
end)
2 Likes

But I have 3 different swings and want the sound to be synced

I saw this, just gotta figure out how to use it

That will take some more code. I’m not currently home, but if you can wait, I’ll help out as soon as I’m home and have the time to.

Sweet! I’ve just gotta figure out where in the script to implement it. Because from that that post explains the function rune the second it hits that marker. So I think I just put it anywhere in the script then have the animations run. Then as each animation plays the functions for them will fire and play the sound at the same time as the animation. 2 things I’ve gotta figure out is syncing the sound and swing perfectly (shouldn’t be too hard) and making sure the sounds stop if the animation stop. I know roblox has a lot of built in stuff, so let’s say an animation stops will the sound connected with a marker stop too?

If you use a “wait” parameter you can alter when the sound plays if you don’t want it to play immediately when the script is run, if this is what you’re still confused on.