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

How to make a sound play when I click a brick?

Asked by 10 years ago

I'm trying to make an audio play when I click on a brick. Also, before I continue... It's a mesh, not a brick... will that make the codes change?

Anyways, I've tried to play around with ClickDetector and Sound ID's but I just can't seem to get it working.

I most likely need to add a script, but I have no idea what to put in it :(

Sorry I can't give more information of this. I am not very fluent with Lua yet...

1 answer

Log in to vote
0
Answered by 10 years ago

Ok this needs alot pf preperation. So first you need a sound and in the sound put in http://www.roblox.com/asset/?id= (here put the sound id), and name the sound to something you will remember. And insert a part with a ClickDetector on it. You also need a localscript and put it in StarterGUI

This is what you put in the localscript!

x = game.Workspace.aaa -- Assuming aaa is the part
y = game.Workspace.lll -- Asumming lll is the Sound

function onClicked(mouse)
    wait(0.1) 
    y:Stop() -- Make sure you stop all other sounds
    wait(2)
    y:Play()
end

x.ClickDetector.MouseClick:connect(onClicked)

You put the localscript in The starter GUI so everyone can hear it

0
On the line 02, It' s telling me "unexpected symbol near '='" Any ideas? connor7000 0 — 10y
0
are you sure you wrote the same thing? chill22518 145 — 10y
0
I edited it! chill22518 145 — 10y
Ad

Answer this question