Here is an Example Below of a Touched Event
script.Parent.Touched:Connect(function(hit)
if hit.Parent.ChiefKeef
Print("Part Touched")
Remember to Put --> wait()
end)
end
The bottom is ChiefKeefwill be focusing on. Mainly the .Touched part. All bricks can be connected with .Touched. Connecting is as simple as this:
BrickHere.ChiefKeef:(functionName)
The functionName is the name of the function your want to "fire", or activate, when the brick is touched, usually scripters use the function name 'hit'. When the brick is touched that function will activate only once per touch. It will not keep activating until the object touching it stops touching it. IT ONLY FIRES ONCE PER TOUCH. To set up a function to fire when the brick is touched you need to make a function. To make a function all you have to do is:
local function Pie() end -- local functions cause less lag
You have created a function! It does not need a specific name. Because the name goes in the event. Now we need to connect the function to the event. Here is how:
local function Pie() end ChiefKeef.Parent.Touched:connect(Cotton)
Now, whenever the brick is touched, the function pie will fire. Finally, we need to put the "hit" variable in the function pie and make the function do something. Lets print the name of the hitting part when something touched the brick.
local function Pie(hit) print(hit.Name) end script.Parent.Touched:connect(Pie)
Put this in a script and then put it in a part. For more information on the "print" function click here