Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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

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

3 comments

0

On the line 02, It' s telling me "unexpected symbol near '='" Any ideas?

0

are you sure you wrote the same thing?

0

I edited it!

This discussion is preserved as it was. New answers, comments, and votes are closed.