So I want to know do I need a ClickDetector to make click action on a brick?
COMMUNITY QUESTION
Do I need to have a ClickDetector to trigger a click action?
3 answers
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.
script.Parent.ClickDetector.MouseClick:connect(function(playerWhoClicked)
print("Part was clicked by: " .. playerWhoClicked.Name) --Finds out who clicked it and prints it.
end)
Yes. Here's an example:
button = script.Parent
function ghost()
button.Transparency = 0.5
end
button.ClickDetector.MouseClick:connect(ghost)
Not necessarily, you can do
local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()
local Button = script.Parent
Mouse.Button1Down:connect(function()
if Mouse.Target == Button then
print("I was clicked")
end)
It does have its disadvantages though
This discussion is preserved as it was. New answers, comments, and votes are closed.

2 comments
Yes
No, you do not need to use ClickDetectors. You can use things such as mouse.Hit, mouse.Target, etc.