generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: How do i make a block play a sound when you click on it?

Previous Thread :: Next Thread 
Themegaman33 is not online. Themegaman33
Joined: 08 May 2014
Total Posts: 108
13 May 2014 01:49 PM
ive tried looking it up on the internet and ive tried writing it mysel but i cant figure it out how to do it, how do i make it so when you click on a block it plays a sound?
Report Abuse
Kapitanovas is not online. Kapitanovas
Joined: 09 Sep 2012
Total Posts: 4216
13 May 2014 02:33 PM
do u want exactly a Click Brick or will an onTouch Brick do while I make 1 with ClickDetector?
Report Abuse
DeSpizer27 is not online. DeSpizer27
Joined: 13 Jul 2012
Total Posts: 2679
13 May 2014 02:49 PM
1. Insert a ClickDetector into the brick
2. Insert your sound into your brick
3. Insert a script into the brick
4. Put this inside the script;

local debounce = false

script.Parent.MouseClick:connect(function()
debounce = true
script.Parent.Sound:Play() --change Sound to the name of your sound
debounce = false
end
Report Abuse
Kapitanovas is not online. Kapitanovas
Joined: 09 Sep 2012
Total Posts: 4216
13 May 2014 02:53 PM
u dont need a debounce for ClickDetectors...
Report Abuse
DeSpizer27 is not online. DeSpizer27
Joined: 13 Jul 2012
Total Posts: 2679
13 May 2014 02:53 PM
They can spam the button.
Report Abuse
Seizurezxzz is not online. Seizurezxzz
Joined: 12 Feb 2013
Total Posts: 1297
13 May 2014 02:58 PM
True ^^
Report Abuse
Themegaman33 is not online. Themegaman33
Joined: 08 May 2014
Total Posts: 108
13 May 2014 03:34 PM
i'll try it out thanks
Report Abuse
Themegaman33 is not online. Themegaman33
Joined: 08 May 2014
Total Posts: 108
14 May 2014 03:46 AM
it didnt work any other ideas?
Report Abuse
nacker is not online. nacker
Joined: 06 Oct 2009
Total Posts: 6034
14 May 2014 06:36 AM
local debounce = true

function clicked ()
if debounce == true then
debounce = false
script.Parent.Sound:Play()
wait(0.3)
debounce = true
end
end

script.Parent.MouseClick:connect(clicked)
Report Abuse
DeSpizer27 is not online. DeSpizer27
Joined: 13 Jul 2012
Total Posts: 2679
14 May 2014 09:49 AM
@Knacker sorry, just saw I messed up debounce.
Report Abuse
Themegaman33 is not online. Themegaman33
Joined: 08 May 2014
Total Posts: 108
14 May 2014 11:31 AM
it keeps saying "connect is not a valid member of clickdetector" am i missing something?
Report Abuse
DeSpizer27 is not online. DeSpizer27
Joined: 13 Jul 2012
Total Posts: 2679
14 May 2014 11:34 AM
script.Parent.ClickDetector.MouseClick:connect
Report Abuse
noah is not online. noah
Joined: 11 Sep 2006
Total Posts: 18977
14 May 2014 11:39 AM
Optional: Preload the song first so the sound will finish loading before playing
Report Abuse
islandmaker2012 is not online. islandmaker2012
Joined: 07 Nov 2012
Total Posts: 9327
14 May 2014 11:39 AM
@mega
script.Parent.ClickDetector.MouseClick:connect(functioname)

put the script into the brick
Report Abuse
Azeroth17 is not online. Azeroth17
Joined: 13 May 2014
Total Posts: 86
14 May 2014 11:41 AM


local debounce = false

script.Parent.ClickDetector.MouseClick:connect(function()
if not debounce then
debounce = true
script.Parent.Sound:Play() --change Sound to the name of your sound
debounce = false
end
end
Report Abuse
Azeroth17 is not online. Azeroth17
Joined: 13 May 2014
Total Posts: 86
14 May 2014 11:42 AM
Accidentally deleted the bracket somehow.


local debounce = false

script.Parent.ClickDetector.MouseClick:connect(function()
if not debounce then
debounce = true
script.Parent.Sound:Play() --change Sound to the name of your sound
debounce = false
end
end)
Report Abuse
islandmaker2012 is not online. islandmaker2012
Joined: 07 Nov 2012
Total Posts: 9327
14 May 2014 11:42 AM
so it should look like this

Part
-Script
-ClickDetector
-Sound
Report Abuse
Themegaman33 is not online. Themegaman33
Joined: 08 May 2014
Total Posts: 108
14 May 2014 03:06 PM
ITS WORKED!!

Thank you everyone :D
Report Abuse
Themegaman33 is not online. Themegaman33
Joined: 08 May 2014
Total Posts: 108
14 May 2014 03:07 PM
IT*
Report Abuse
JigglingJack is not online. JigglingJack
Joined: 25 Mar 2014
Total Posts: 11263
14 May 2014 03:09 PM
They can still spam the clicks because debounce turns off right after playing the sound

JigglingJack -- Starting At $21,545 [ Locate a dealer now ] [ Bid now ] [ Buy now ]
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image