Instrument Tutorial (By Jim D: )
ApramFri, 04 Apr 2008 10:32:54 +00002008-04-04T10:32:54+00:0010 29, 2008
How to make Instruments

OK, so last time you made a door. So what? A door’s easy
Making a musical instrument in Roblox is slightly harder!
STEP 1
You make the main frame of your instrument. For examples sake, lets say a piano. Make everything but the keys.
STEP 2
As we are making a piano, make a white block, however large you want, so that it will fit inside your piano (How big your piano is decides how many keys you want.) For this example we will call the key *C*
STEP 3
Now that we have the white block click on it, then go to Insert, Object… and click on the Click Detector.
STEP 4
Now you need to insert a sound into to the workspace. To do this unselect any objects, and go into Insert, Object… and click on Sound. Now you can add the sound you want to play when you press the key
(If you are having trouble finding some sounds, I have uploaded the .Zip for my place, inside it are 17 piano notes, 4 guitar notes and some drum sounds. http://www.mediafire.com/?yjsc3iy4gxj is where it is.)
STEP 4
Now select the sound and the ‘C’ object and group them together as a model. Give the model a descriptive name, like ‘Ckey’.
STEP 5
Click on the model and go to Insert, Object… and click on script. Now open up the script in the model and get rid of the Print Hello World script and paste in this:
function onClicked()
script.Parent.C.BrickColor = BrickColor.new(21)
script.Parent.Sound:play()
wait(0.25)
script.Parent.C.BrickColor = BrickColor.new(1)
end
script.Parent.C.ClickDetector.MouseClick:connect(onClicked)
STEP 6
Now go into solo mode and try pressing the key. It should make a noise and change color if you did it right.
NOW LETS TAKE A CLOSER LOOK AT THE SCRIPT!
function onClicked() –This says if the user clicks on the brick
script.Parent.C.BrickColor = BrickColor.new(21) –This changes the color of the key when it is pressed!
script.Parent.Sound:play() –This plays the sound
wait(0.25) –Wait for a quater of a second
script.Parent.C.BrickColor = BrickColor.new(1) –Changes the color of the key back to normal.
end
script.Parent.C.BrickColor = BrickColor.new(1) –Changes the color of the key back to normal.
end
script.Parent.C.ClickDetector.MouseClick:connect(onClicked) –This makes sure the Click Detecting process works.
Now just one more thing. If you need the color codes so you can have all sort of color changes in the key, here is a link to the picture in the Roblox Wiki:
Right, with some imagination, you can use this tutorial to do a WHOLE LOAD of things.
Good luck! (If you liked this tutorial, please visit my place! It is full of musical instruments: http://www.roblox.com/Place.aspx?ID=301773
Toodle-oo!
Jimjambo
Entry Filed under: 1. .
1.
Wirodeu | AprpmFri, 04 Apr 2008 13:41:38 +00002008-04-04T13:41:38+00:0001 29, 2008 at 9:39
Nice tutorial!
However, to make the script work with colors other than white, use this:
local color = script.Parent.C.BrickColor
function onClicked()
script.Parent.C.BrickColor = BrickColor.new(21)
script.Parent.Sound:play()
wait(0.25)
script.Parent.C.BrickColor = color
end
script.Parent.C.ClickDetector.MouseClick:connect(onClicked)
Now you don’t have to edit the script to make the color return to the previous script all the time
2.
jimjambo | AprpmFri, 04 Apr 2008 13:42:49 +00002008-04-04T13:42:49+00:0001 29, 2008 at 9:39
What a nice add
Thanks for that comment Wirodeu, it should make it easier.
3.
SilverBreegull | AprpmSun, 06 Apr 2008 20:50:29 +00002008-04-06T20:50:29+00:0008 29, 2008 at 9:39
That’s an awesome place
I played a little bit of drum lol.
4.
driggz95 | ApramSun, 27 Apr 2008 08:49:17 +00002008-04-27T08:49:17+00:0008 29, 2008 at 9:39
hold on a sec….what if, the track goes on for 5 seconds and i dont want it to mix with the other sounds….how do i do that?
5.
jimjambo | ApramSun, 27 Apr 2008 11:35:14 +00002008-04-27T11:35:14+00:0011 29, 2008 at 9:39
Disable the Clickdetector when it is clicked, then enable it again after 5 seconds. I can’t remember EXACTLY how it is, but it should be like:
Script.Parent.C.ClickDetector.Enabled = true/false
Hope this works. S:
6.
hugeflare | AprpmSun, 27 Apr 2008 15:46:07 +00002008-04-27T15:46:07+00:0003 29, 2008 at 9:39
What does that have to do with it bieng 5 seconds? Q_Q
7.
jimjambo | AprpmMon, 28 Apr 2008 16:01:31 +00002008-04-28T16:01:31+00:0004 29, 2008 at 9:39
…
You’d add a wait 5… YA? >_<
8.
Lilski | NovamWed, 05 Nov 2008 02:52:30 +00002008-11-05T02:52:30+00:0002 29, 2008 at 9:39
XD seeriously?