So I want to know do I need a ClickDetector to make click action on a brick?
Yes, you need a ClickDetector to make a click work on a brick.
Heres an example that you would include inside a script located under the brick.
1 | script.Parent.ClickDetector.MouseClick:connect( function (playerWhoClicked) |
2 | print ( "Part was clicked by: " .. playerWhoClicked.Name) --Finds out who clicked it and prints it. |
3 | end ) |
Yes. Here's an example:
1 | button = script.Parent |
2 | function ghost() |
3 | button.Transparency = 0.5 |
4 | end |
5 | button.ClickDetector.MouseClick:connect(ghost) |
Not necessarily, you can do
1 | local Player = game.Players.LocalPlayer |
2 | local Mouse = Player:GetMouse() |
3 | local Button = script.Parent |
4 |
5 | Mouse.Button 1 Down:connect( function () |
6 | if Mouse.Target = = Button then |
7 | print ( "I was clicked" ) |
8 | end ) |
It does have its disadvantages though