cheez55
|
  |
| Joined: 19 Oct 2008 |
| Total Posts: 646 |
|
|
| 13 Aug 2011 07:18 PM |
| What's the script connection line for a key press? |
|
|
| Report Abuse |
|
|
|
| 13 Aug 2011 07:19 PM |
Mouse.KeyDown:connect(function(key) if key == "t" then print("Win") end |
|
|
| Report Abuse |
|
|
1waffle1
|
  |
| Joined: 16 Oct 2007 |
| Total Posts: 16381 |
|
|
| 13 Aug 2011 07:19 PM |
| Mouse.KeyDown:connect(function(key) end) |
|
|
| Report Abuse |
|
|
swmaniac
|
  |
| Joined: 28 Jun 2008 |
| Total Posts: 15773 |
|
|
| 13 Aug 2011 07:20 PM |
For some reason the keyboard is part of the mouse object, so you need to get the mouse first.
The only way to do that is through a tool or hopperbin's equipped and selected events (respectively).
script.Parent.Equipped:connect(function(mouse)
end)
From there, it's easy.
script.Parent.Equipped:connect(function(mouse) mouse.KeyDown:connect(function(key) end) mouse.KeyUp:connect(function(key) end)
end)
KeyDown and KeyUp events return what key was pressed/released. I used key in that script.
NOTE: Both of these events disconnect when the tool is unequipped. |
|
|
| Report Abuse |
|
|
|
| 13 Aug 2011 07:21 PM |
| I'll post how to get a global mouse :T |
|
|
| Report Abuse |
|
|
1waffle1
|
  |
| Joined: 16 Oct 2007 |
| Total Posts: 16381 |
|
|
| 13 Aug 2011 07:21 PM |
| He only asked for the connection line... Not a book. |
|
|
| Report Abuse |
|
|
| |
|
|
| 13 Aug 2011 07:23 PM |
function _G.GetMouse() Tool = Instance.new("Tool") Part = Instance.new("Part") Part.Name = "Handle" Part.Parent = Tool Tool.Equipped:connect(function(Mouse) _G["Mouse"] = Mouse Tool.Parent = nil end) Tool.Parent = game.Players.LocalPlayer.Character end _G.GetMouse() |
|
|
| Report Abuse |
|
|
swmaniac
|
  |
| Joined: 28 Jun 2008 |
| Total Posts: 15773 |
|
|
| 13 Aug 2011 07:24 PM |
@1waffle1
Explaining it to them means they don't have to come back later if they don't understand something else. |
|
|
| Report Abuse |
|
|
cheez55
|
  |
| Joined: 19 Oct 2008 |
| Total Posts: 646 |
|
|
| 13 Aug 2011 07:33 PM |
| @DarkMist on first reply: The output says that Mouse is a nil value. Is it supposed to be a variable? |
|
|
| Report Abuse |
|
|
swmaniac
|
  |
| Joined: 28 Jun 2008 |
| Total Posts: 15773 |
|
|
| 13 Aug 2011 07:34 PM |
... cheez, thank you for indirectly validating why I gave you the full tutorial. Please read my post now. |
|
|
| Report Abuse |
|
|