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