I made different tools in my 3 months, what i dont know is how a tool plays a sound when it is clicked. I am currently working on a simulator and i want to know how to code. ive had several local scripts but they all dont work.
1 | local Sword = script.Parent |
2 |
3 | Sword.Equipped:connect( function () – Fires when equipped |
4 | Sword.Handle.EquipSound:Play() – Plays equip sound |
5 | end ) |
6 |
7 | Sword.Activated:connect( function () – Fires when clicked while equipped |
8 | Sword.Handle.SlashSound:Play() --Plays slash sound |
9 | end ) |
my only guess is that the sound isnt loaded, the sound was removed, or the sound on your pc/in your properties is set to 0, the below script worked for me so u should probs check your sound and also add a :WaitForChild()
01 | local tool = script.Parent --The tool |
02 | local sound = script:WaitForChild( 'Sound' ) --Change to the sounds location |
03 |
04 | tool.Activated:Connect( function () --Fires when the tool is activated |
05 | sound:Play() --plays the sound |
06 | end ) |
07 |
08 | tool.Equipped:Connect( function () --Fires when the tool is Equipped |
09 | sound:Play() --plays the sound |
10 | end ) |
if i fixed your problem please accept my answer! if theres any issues ping me in the community chat and i'll be happy to help!
2 things:
1) Make a variable for each sound. 2) Use :Connect!
That's all, any errors in the output? Also a very useful tip: Use Print() to detect if a function is functioning :)