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: Using keys with tools

Previous Thread :: Next Thread 
jegabert is not online. jegabert
Joined: 11 Mar 2009
Total Posts: 3515
02 May 2013 02:04 PM
I have a basic sword, When I press "Q" I want the the script in the sword to print "Boop"

So far I found this.

local tool = script.Parent
tool.Selected:connect(function(mouse)
mouse.KeyDown:connect(function(key)
if key == "q" then
print("BEEEP")
end
end)
end)

But When I activate the took I get this:

Disconnected event because of exception
Selected is not a valid member of Tool
Report Abuse
jegabert is not online. jegabert
Joined: 11 Mar 2009
Total Posts: 3515
02 May 2013 02:09 PM
I am stuck, I got most of that segment from the wiki.
Report Abuse
btft is not online. btft
Joined: 19 Feb 2011
Total Posts: 1512
02 May 2013 02:11 PM
That code only works in a local script in a hopperbin.
Report Abuse
jegabert is not online. jegabert
Joined: 11 Mar 2009
Total Posts: 3515
02 May 2013 02:12 PM
Is there an eqivelant to it for normal tools?
Report Abuse
veerstrong is not online. veerstrong
Joined: 23 Jun 2009
Total Posts: 2450
02 May 2013 02:13 PM
Tool doesn't use "Selected"

It uses "Equipped"

For more information, check out the wiki page :D

http://wiki.roblox.com/index.php/RBX.lua.Tool_%28Object%29
Report Abuse
btft is not online. btft
Joined: 19 Feb 2011
Total Posts: 1512
02 May 2013 02:14 PM
Tool.Equipped:connect(function(mouse)
mouse.KeyDown:connect(function(key)
print(key)
end)
end)
Report Abuse
jegabert is not online. jegabert
Joined: 11 Mar 2009
Total Posts: 3515
02 May 2013 02:15 PM
excellent! thank you.

I have scripted a few things but never tools, I am not used to all of the syntax for tools.
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