How to check if a specific click detector was clicked out of multiple?

I’m taking a closer look at click detectors.

I’ve searched the devforum but I haven’t found an answer to this. I was wondering if there’s a way for a script to check or run once a specific click detector was clicked out of multiple. I was preferably looking for a ““if then”” sort of script method. Any help is appreciated. Thank you!

3 Likes

Could you explain what “clicked out of multiple” is?

Edit: If you want a script or function to run once the click detector has been clicked multiple times you should use a variable

3 Likes

Sure.

I was wondering if there was a way to check if a specific click detector was clicked and to have the script respond to that click.

For example (original):

Route = game.Workspace.Model.Part

function onClicked()

-- action here

Route.ClickDetector.MouseClick:connect(onClicked)

For example (ideal):

Route = game.Workspace.Model.Part
Route2 = game.Workspace.Model2.Part

function onClicked()
if (Area of question here) (Is there a way to check for a specific click) then
-- action here

Route.ClickDetector.MouseClick:connect(onClicked)
Route2.ClickDetector.MouseClick:connect(onClicked)

So you want to check which click detector the player clicked, if so then you should just use a function instead of just connecting.

Route.ClickDetector.MouseClick:Connect(function(Player)
    onClicked(Player, Route)
end)