jbn011
|
  |
| Joined: 30 Aug 2010 |
| Total Posts: 479 |
|
|
| 26 Jul 2016 01:45 PM |
How would you do detect if the player presses a key while seated?
For example, detecting if the key Q is held down/pressed. |
|
|
| Report Abuse |
|
|
DeGames
|
  |
| Joined: 08 Sep 2012 |
| Total Posts: 1028 |
|
|
| 26 Jul 2016 01:46 PM |
| http://wiki.roblox.com/index.php?title=Keyboard_input |
|
|
| Report Abuse |
|
|
jbn011
|
  |
| Joined: 30 Aug 2010 |
| Total Posts: 479 |
|
|
| 26 Jul 2016 01:52 PM |
| How would you connect that though with a seat? |
|
|
| Report Abuse |
|
|
|
| 26 Jul 2016 01:52 PM |
| Teleport them to the seat, and active "sit" in humanoid? I dont really know |
|
|
| Report Abuse |
|
|
DeGames
|
  |
| Joined: 08 Sep 2012 |
| Total Posts: 1028 |
|
|
| 26 Jul 2016 01:57 PM |
if Humanoid.sit
and i found someone say something like
"function oAdd(object) --stuff end function oRem(object) --stuff end script.Parent.ChildAdded:connect(oAdd) script.Parent.ChildRemoved:connect(oRem)
Put that script inside the seat" |
|
|
| Report Abuse |
|
|
Naxxanar
|
  |
| Joined: 13 Jun 2012 |
| Total Posts: 709 |
|
|
| 26 Jul 2016 02:07 PM |
bleh idk
never tried it but im too lazy and will just write what i would think would work
put this in a client sided script:
--Made by Naxxanar
local Players = Game:GetService('Players'); local Player = Players.LocalPlayer; repeat Wait(0) until Player.Character; local Character = Player.Character; local Humanoid = Character.Humanoid;
local Sit = false;
local UserInputService = Game:GetService('UserInputService');
UserInputService.InputBegan:connect(function(Input, GPE) if not GPE then if Input.KeyCode == Enum.KeyCode.Q then if Sit == true then warn('Available: Seated & pushed'); else warn('Unavailable: Unseated & pushed'); end end end end)
Humanoid.Seated:connect(function() if Sit == false then Sit = true print('Seated'); end end)
Humanoid.Jumping:connect(function() if Sit == true then Sit = false print('Unseated'); end end) Enum.KeyCode.Q then if Sit == true then print('Pressed'); else print('Unavailable'); end end end end)
|
|
|
| Report Abuse |
|
|
Naxxanar
|
  |
| Joined: 13 Jun 2012 |
| Total Posts: 709 |
|
|
| 26 Jul 2016 02:09 PM |
unfortunately the text mashed together so maybe like this
--Made by Naxxanar
local Players = Game:GetService('Players'); local Player = Players.LocalPlayer; repeat Wait(0) until Player.Character; local Character = Player.Character; local Humanoid = Character.Humanoid;
local Sit = false;
local UserInputService = Game:GetService('UserInputService');
UserInputService.InputBegan:connect(function(Input, GPE) if not GPE then if Input.KeyCode == Enum.KeyCode.Q then if Sit == true then warn('Available: Seated & pushed'); else warn('Unavailable: Unseated & pushed'); end end end end)
Humanoid.Seated:connect(function() if Sit == false then Sit = true print('Seated'); end end)
Humanoid.Jumping:connect(function() if Sit == true then Sit = false print('Unseated'); end end)
|
|
|
| Report Abuse |
|
|
jbn011
|
  |
| Joined: 30 Aug 2010 |
| Total Posts: 479 |
|
|
| 26 Jul 2016 02:17 PM |
| I just tried it and nothing seemed to happen |
|
|
| Report Abuse |
|
|
jbn011
|
  |
| Joined: 30 Aug 2010 |
| Total Posts: 479 |
|
|
| 26 Jul 2016 02:20 PM |
| There were no errors either |
|
|
| Report Abuse |
|
|
Naxxanar
|
  |
| Joined: 13 Jun 2012 |
| Total Posts: 709 |
|
|
| 26 Jul 2016 02:31 PM |
Basically it does what you said: If the player is seated, and they press Q, it will operate functionally, but if they are unseated and press Q, nothing happens
If you are able to script yourself, you should be able to make additional things.
|
|
|
| Report Abuse |
|
|
Naxxanar
|
  |
| Joined: 13 Jun 2012 |
| Total Posts: 709 |
|
|
| 26 Jul 2016 02:32 PM |
>For example, detecting if the key Q is held down/pressed.
Open the Output and press Q while seated and unseated on a seat and you'll see
|
|
|
| Report Abuse |
|
|