Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

When Is it better to use a clickdetector or mouse..Target?

Asked by
Yeevivor4 155
9 years ago

hi, thanks for reading. Sorry, I'm in iPad so the grammar is bad. Anyways, I was wondering, why did they make two separate functions that sort of serve the same function? Both of them are basically going to identify what's clicked anyway. Can anyone explain to me why this is?

Thanks for reading.

2 answers

Log in to vote
0
Answered by
iaz3 190
9 years ago

A click detector is located in a part or model, and you can only click said part/model.

Without mouse.target you could click anything and everything, and with no regards to distance, unless you implemented checking for that yourself.

A clickdetector is what is generally used, while you may want to use mouse.Target for advanced purposes.

Furthermore, a clickdetector is on the server, and again, only allows clicking of the object it is located in. This is what you usually want, to click one object

With mouse.Target, you first have to get their mouse, which means a local script or a tool, and then get mouse.Target, possibly implement distance checking, name checking, plus every player will need to have a localscript with the code to be able to click whatever you want clicked, adding to memory usage.

mouse.Target could be, and was, used, for example, to make buttons that would only open if the right player clicked them, but clickdetectors now give you the player who clicked them, making this unnecessary

Ad
Log in to vote
0
Answered by 9 years ago

You can't check if you click a specific instance using mouse.Target, especially if it has duplicates under the same name and parent. For instance, if you wanted to have it to where if you click a model where there are duplicates in the workspace and you want that model to do something, if you used mouse.Target you'd have to check many things to specify how it's unique. The click detector just works as a shortcut, because you can reference what part is clicked from the script's perspective.

Answer this question