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: On Key down

Previous Thread :: Next Thread 
Truste135 is not online. Truste135
Joined: 26 Oct 2010
Total Posts: 741
29 Sep 2012 06:11 AM
function onKeyDown(key)
key:lower()
if key == "f" then
script.Parent.Parent.Parent.Character.Humanoid.Health = 0
end

[Now, whats the connection line again? ]

Report Abuse
Truste135 is not online. Truste135
Joined: 26 Oct 2010
Total Posts: 741
29 Sep 2012 06:14 AM
Probably:

script.Parent.Selected:connect(onSelected)

lemme try.
Report Abuse
FlightTheory is not online. FlightTheory
Joined: 29 Sep 2011
Total Posts: 156
29 Sep 2012 06:14 AM
Well, you need to target your mouse, you can do so whenever you equip the tool or hopperbin. Once you have the mouse targeted, you can connect your onKeyDown function into the code with:

mouse.KeyDown:connect(onKeyDown)

Here is a helpful link to the wiki if you want to get even more information on it.
http://wiki.roblox.com/index.php/Equipped_(Event)

Here to help,
`FlightTheory
Report Abuse
TheMyrco is not online. TheMyrco
Joined: 13 Aug 2011
Total Posts: 15105
29 Sep 2012 06:17 AM
"Once you have the mouse targeted, you can connect your onKeyDown function into the code with:

mouse.KeyDown:connect(onKeyDown)"

That lacks a lot of information.

An connection line connects an event to the given function between the parameters. As in this script, the function is ´onKeyDown´. You could also make anonymous functions by directly making the function inside the parenthesis.

':connect(f)' is a method, the f is the function as described above.
Report Abuse
FlightTheory is not online. FlightTheory
Joined: 29 Sep 2011
Total Posts: 156
29 Sep 2012 06:20 AM
Well indeed you could. Let's make things more complicated for them, shall we?

`FlightTheory
Report Abuse
TheMyrco is not online. TheMyrco
Joined: 13 Aug 2011
Total Posts: 15105
29 Sep 2012 06:22 AM
You barely included information. You should include information, but not over complicate it and not supress the person by word-walls.

An example of what you did; Here is a box. It has many buttons and yes I know it's kinda hard to understand at first, but if you press a button it will explode. Have fun. *BOOM*
Report Abuse
FlightTheory is not online. FlightTheory
Joined: 29 Sep 2011
Total Posts: 156
29 Sep 2012 06:23 AM
Well, I guess my way of wording it may have been a bit off, but it can't be that bad. If he couldn't understand what I posted, he has a direct link to a page that can help him out.

`FlightTheory
Report Abuse
TheMyrco is not online. TheMyrco
Joined: 13 Aug 2011
Total Posts: 15105
29 Sep 2012 06:25 AM
Linking pages won't always help things and could even over-complicate things...
But really, how else would he ever learn how anonymous functions work and how to use the connect method at its fullest?
Report Abuse
FlightTheory is not online. FlightTheory
Joined: 29 Sep 2011
Total Posts: 156
29 Sep 2012 06:27 AM
Okay, seems you got me there.
`FlightTheory
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