Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How might I be able to add sound to a script when on impact?

Asked by 10 years ago

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?

2 answers

Log in to vote
0
Answered by 10 years ago
1script.Parent.Touched:connect(function()
2local sound = Instance.new("Sound", script.Parent) --Second argument is the parent
3Sound.SoundId = SoundIdHere --Replace this with a sound ID
4Sound.Volume = 1
5Sound.Pitch = 1
6Sound:play()
7wait(Sound.TimeLength) --I don't think this works yet.
8Sound:remove() --Or :Destroy()
9end)

This script adds a sound with the explosion sound when touched by anything.

Ad
Log in to vote
0
Answered by 10 years ago

****Put into a part with the sound you want it to play, Change ONLY WHATS ASKED

1Sound = Script.Parent:FindFirstChilD("SOUNDNAMEHERE") -- Replace with name of song
2function onTouched(hit)
3Sound:Play()
4end
5script.Parent.Touched:connect(onTouched)
0
What if the sound doesn't exist? EzraNehemiah_TF2 3552 — 10y
0
put this into the part and add the sound with it ioutragous 0 — 10y

Answer this question