roblock59
|
  |
| Joined: 30 Jul 2010 |
| Total Posts: 155 |
|
|
| 04 Apr 2015 03:29 PM |
| Lets say if I hold down "c" the function keeps repeating till I let go how do i do this I got everything set up just need help with this x3. |
|
|
| Report Abuse |
|
|
amanda
|
  |
| Joined: 21 Nov 2006 |
| Total Posts: 5925 |
|
|
| 04 Apr 2015 03:31 PM |
local UIS = game:GetService('UserInputService')
UIS.InputBegan:connect(function(inputObject, gameProcessedEvent) if not gameProcessedEvent then if inputObject.KeyCode == Enum.InputObject.C then print('C why u should use UserInputService now?') end end end)
|
|
|
| Report Abuse |
|
|
|
| 04 Apr 2015 03:32 PM |
down=false
mouse.KeyDown:connect(function(key) if key:lower()=="c" then down=true repeat print('hi') until not down end end)
mouse.KeyUp:connect(function(key) if key:lower()=="c" then down=false end end) |
|
|
| Report Abuse |
|
|
|
| 04 Apr 2015 03:32 PM |
UserInputService is a lot more efficient and I recommend using it. Not to mention it's compatible with mobile. |
|
|
| Report Abuse |
|
|
rayk999
|
  |
| Joined: 18 Feb 2011 |
| Total Posts: 4705 |
|
|
| 04 Apr 2015 03:33 PM |
you should use UserInputService but you want the mouse
mouse = game.Players.LocalPlayer:GetMouse()
holdingkey = false
mouse.KeyDown:connect(function(key) if key == "c" then holdingkey = true while holdingkey do --stuff end end end)
mouse.KeyUp:connect(function(key) if key == "c" then holdingkey = false end end) |
|
|
| Report Abuse |
|
|
amanda
|
  |
| Joined: 21 Nov 2006 |
| Total Posts: 5925 |
|
|
| 04 Apr 2015 03:35 PM |
local UIS = game:GetService('UserInputService') local pressing
UIS.InputBegan:connect(function(inputObject, gameProcessedEvent) if not gameProcessedEvent then if inputObject.KeyCode == Enum.InputObject.C then pressing = true while pressing do print('C why u should use UserInputService now?') wait(.2) end end end end)
UIS.InputEnded:connect(function(inputObject, gameProcessedEvent) if not gameProcesedEvent then if inputObject.KeyCode == Enum.InputObject.C then pressing = false print('u stopped pressing :)') end end end) |
|
|
| Report Abuse |
|
|
amanda
|
  |
| Joined: 21 Nov 2006 |
| Total Posts: 5925 |
|
|
| 04 Apr 2015 03:37 PM |
lol im dumb
i messed up the Enum.
Here's a working version I tested:
local UIS = game:GetService('UserInputService') local pressing
UIS.InputBegan:connect(function(inputObject, gameProcessedEvent) if not gameProcessedEvent then if inputObject.KeyCode == Enum.KeyCode.C then pressing = true while pressing do print('C why u should use UserInputService now?') wait(.2) end end end end)
UIS.InputEnded:connect(function(inputObject, gameProcessedEvent) if not gameProcessedEvent then if inputObject.KeyCode == Enum.KeyCode.C then pressing = false print('u stopped pressing :)') end end end) |
|
|
| Report Abuse |
|
|
roblock59
|
  |
| Joined: 30 Jul 2010 |
| Total Posts: 155 |
|
| |
|