How might I be able to add sound to a script when on impact? I have a touchable explosion brick, but how do I add the 'explosion' sound to it?
1 | script.Parent.Touched:connect( function () |
2 | local sound = Instance.new( "Sound" , script.Parent) --Second argument is the parent |
3 | Sound.SoundId = SoundIdHere --Replace this with a sound ID |
4 | Sound.Volume = 1 |
5 | Sound.Pitch = 1 |
6 | Sound:play() |
7 | wait(Sound.TimeLength) --I don't think this works yet. |
8 | Sound:remove() --Or :Destroy() |
9 | end ) |
This script adds a sound with the explosion sound when touched by anything.
****Put into a part with the sound you want it to play, Change ONLY WHATS ASKED
1 | Sound = Script.Parent:FindFirstChilD( "SOUNDNAMEHERE" ) -- Replace with name of song |
2 | function onTouched(hit) |
3 | Sound:Play() |
4 | end |
5 | script.Parent.Touched:connect(onTouched) |