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
script.Parent.Touched:connect(function()
local sound = Instance.new("Sound", script.Parent) --Second argument is the parent
Sound.SoundId = SoundIdHere --Replace this with a sound ID
Sound.Volume = 1
Sound.Pitch = 1
Sound:play()
wait(Sound.TimeLength) --I don't think this works yet.
Sound:remove() --Or :Destroy()
end)

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

Sound = Script.Parent:FindFirstChilD("SOUNDNAMEHERE") -- Replace with name of song
function onTouched(hit)
Sound:Play()
end
script.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