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

Trying to make a sound trigger script. Help?

Asked by 8 years ago

This is what I've got so far.

function onTouched(hit)
script.Parent.Sound:play()
if script.Parent.TouchEnded then
script.Parent.Sound.IsPlaying=false
end
end

script.Parent.touched:connect(onTouched)

When the brick is touched, the sound will play. But when the brick is not being touched anymore, the sound stops. When the brick is touched again, the sound plays again. So if the brick was as big as the place where the music would play, it could provide background music. For example, if the brick was the same size as a supermarket, it would play when the player steps into it and would cease when the player steps out of it.

0
What? Also, don't use this method for providing music for a specific area. Making a huge brick like that with the touched event would be laggy and glitchy. User#11440 120 — 8y
0
@wfv014 is there any other way I could accomplish this then? mynameischrome 5 — 8y
0
You'd need to do something such as Region3, not really sure how it would work exactly, but that's what I'd try. PreciseLogic 271 — 8y

1 answer

Log in to vote
0
Answered by 8 years ago

If you're trying to make it trigger different sounds on different areas, just have a block that triggers the noise once they enter the area, and have a block that ends the noise after they leave that are. You could use that current script you have, but modify it to trigger only and have the same script in another block but have it end when its touched.

Ad

Answer this question