Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do i make a tool play a sound when clicked?

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.

local Sword = script.Parent

Sword.Equipped:connect(function() – Fires when equipped
Sword.Handle.EquipSound:Play() – Plays equip sound
end)

Sword.Activated:connect(function() – Fires when clicked while equipped
Sword.Handle.SlashSound:Play() --Plays slash sound
end)

2 comments

1

The script is probably not working because of the 2 lines "– Fires when equipped" and "– Plays equip sound" instead use -- instead of an endash

0

oh

2 answers

✓ Accepted answer

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()

local tool = script.Parent --The tool
local sound = script:WaitForChild('Sound') --Change to the sounds location

tool.Activated:Connect(function() --Fires when the tool is activated
	sound:Play() --plays the sound
end)

tool.Equipped:Connect(function() --Fires when the tool is Equipped
	sound:Play() --plays the sound
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 comments

0

i forgot to rename the sound, Thanks!

0

np

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 :)

This discussion is preserved as it was. New answers, comments, and votes are closed.