Hello there, I recently made a custom sword, with on-key animations, and everything works except for the sound, my sword only functions when you press certain keys, and the sound only seems to play if I click.
Is there a way for my sword to have sound?
It also may or may not be a problem that my Handle is a MeshPart.
Well for the function bound to Equipped, it’s try to find an object called ‘EquipSound’ in Handle. As we can see, there is not a sound there called EquipSound – but there is a sound called ‘Unsheath’.
Secondly the function bound to Activated also would not work because there is not an object called ‘SlashShound’ in Handle. Same deal - you are probably looking for ‘Slash’ instead.
Also, :connect() is deprecated, use :Connect().
Code:
Sword.Equipped:Connect(function()
Sword.Handle.Unshealth:Play() -- note that both the object's name and the spelling on this line is incorrect - it's 'unsheath' not 'unshealth'
end)
Sword.Activated:Connect(function()
Sword.Handle.Slash:Play()
end)
Sorry about the connect thing; I’m used to using :connect() before it was deprecated. I should have fixed that before posting the code sample on his previous post.
Hey, it worked but it doesn’t play sound when I hit a key (When a key is hit that is when an animation for the sword is played) It’ll only play sound when I click, and nothing happens when I click.
Well the issue here is that you haven’t put sound into the function handles the animations.
Same thing with you’re animations - you’re using animations on a key press, and sounds on a click. Obviously they won’t work together, as they’re separated. If you want them both on a click, you’d put them together:
Sword.Activated:Connect(function()
Sword.Handle.Slash:Play()
-- animation here
end)
Sword.Activated fires whenever you click while having the tool equipped. If you want it to play with the animations, it needs to be of the same event as the animations. You may have to do it from the localscript if that is where you are playing the animations from.