I was just wondering how I could use the touched() function (I believe..) I need it so that when I touch a brick it would wait a certain amount of time, and then remove itself from the workspace. Anyone that can help?
Put this in a script under the part:
script.Parent.Touched:connect(function() --fires when touched wait(5) --waits 5 seconds then destroys brick script.Parent:Destroy() end)
I would recommend going to the wiki first and giving it a try yourself before coming here, it'll help you be a more independent scripter so you won't have to come to us for questions like this. The wiki really does a good job explaining the basics.
Touched is an event.
http://wiki.roblox.com/index.php?title=Touched_(Event)
Events have a connect
method. You give the connect method a function value, and when the event happens (also called fires), the function you connected is called.
Here is a simple script that may be helpful to understanding:
local me = script.Parent; touchedFunction = function(partTouching) print(partTouching,"touched",me); end me.Touched:connect( touchedFunction ); -- me.Touched is event -- We "connect" the function `touchedFunction` to it -- so when the part is touched, `touchedFunction` is called.
It just prints the names of the two parts contacting (where one of them is me
, script.Parent
.)