MattJon
|
  |
| Joined: 28 Apr 2009 |
| Total Posts: 660 |
|
|
| 12 Mar 2013 11:48 AM |
| How do I define the mouse if I am trying to script a Hopperbin tool that utilizes "mouse.Target" |
|
|
| Report Abuse |
|
|
digpoe
|
  |
| Joined: 02 Nov 2008 |
| Total Posts: 9092 |
|
|
| 12 Mar 2013 11:49 AM |
It is returned when you use the Equipped/Selected event.
script.Parent.Selected:connect(function(mouse) if mouse.Target then print(mouse.Target) end end)
And for Tools:
script.Parent.Equipped:connect(function(mouse) if mouse.Target then print(mouse.Target) end end) |
|
|
| Report Abuse |
|
|
MattJon
|
  |
| Joined: 28 Apr 2009 |
| Total Posts: 660 |
|
|
| 12 Mar 2013 12:32 PM |
| So... If I were to insert that little chunk there as a script into a Hopperbin. When I select the Hopperbin it should automatically print my mouse's Target? |
|
|
| Report Abuse |
|
|
MattJon
|
  |
| Joined: 28 Apr 2009 |
| Total Posts: 660 |
|
| |
|
MattJon
|
  |
| Joined: 28 Apr 2009 |
| Total Posts: 660 |
|
| |
|
MattJon
|
  |
| Joined: 28 Apr 2009 |
| Total Posts: 660 |
|
|
| 12 Mar 2013 12:45 PM |
| Please? Anyone? I have NO output when I try that little chunk. It doesn't print anything, nor does it give me any errors. |
|
|
| Report Abuse |
|
|
digpoe
|
  |
| Joined: 02 Nov 2008 |
| Total Posts: 9092 |
|
|
| 12 Mar 2013 12:47 PM |
| Make this the only tool/hopperbin and then press '1' over a part. It should work then. |
|
|
| Report Abuse |
|
|
MattJon
|
  |
| Joined: 28 Apr 2009 |
| Total Posts: 660 |
|
|
| 12 Mar 2013 12:50 PM |
| But.... It doesn't. I have tried multiple times. |
|
|
| Report Abuse |
|
|
MattJon
|
  |
| Joined: 28 Apr 2009 |
| Total Posts: 660 |
|
|
| 12 Mar 2013 12:59 PM |
Ok so I went to the HopperBin wiki page and spliced some things from it together to make a script that prints the target name when the target is a block and is clicked. Here's the script. It works quite nicely. ------------------------------------------------------------------------------------------ function onButton1Down(mouse) local targ = mouse.Target if targ~=nil then if targ.ClassName == "Part" or targ.ClassName == "BasePart" or targ.ClassName == "WedgePart" then print(targ.Name) end end end
function onSelected(mouse) mouse.Button1Down:connect(function() onButton1Down(mouse) end) end script.Parent.Selected:connect(onSelected) ---------------------------------------------------------------------------------------- But now I have a new question. I am thinking about using this general idea and developing it to create an "Interact" or "Info" tool. I know how I could do that for regular models and things, but my question now is, how could I have it identify Terrain Blocks? And distinguish between different types, namely water and grass. If anyone knows, help is appreciated! :) |
|
|
| Report Abuse |
|
|
MattJon
|
  |
| Joined: 28 Apr 2009 |
| Total Posts: 660 |
|
|
| 12 Mar 2013 01:01 PM |
| When I eliminate the fourth line of the script above (plus one of the end's), it will print "Terrain" whenever I click Water or Earth. So my main question is how to make it distinguish between the two? |
|
|
| Report Abuse |
|
|