generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: How do I "index global 'mouse'"

Previous Thread :: Next Thread 
MattJon is not online. 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 is not online. 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 is not online. 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 is not online. MattJon
Joined: 28 Apr 2009
Total Posts: 660
12 Mar 2013 12:32 PM
Because it doesn't :S
Report Abuse
MattJon is not online. MattJon
Joined: 28 Apr 2009
Total Posts: 660
12 Mar 2013 12:40 PM
Ima just Bump this...
Report Abuse
MattJon is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. 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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image