You can use ROBLOX's UserInputService for both PC, and XBox keyboard/controller input.
Here is a link to Gamepad input if you do not already know about it http://wiki.roblox.com/index.php?title=Gamepad_input
As for your script, I have one good idea of what you could do.
Theoretically you could get input through userinputservice, spawn a function that continuously checks how long certain keys/buttons remain down for, and from there depending on how long they remain down change the humanoid's state type back to jumping, essentially allowing the character to continue jumping as long as a key or button is being held down. Now actually programming that will be a different story.
I will use Enum.KeyCode.Space, and Enum.KeyCode.ButtonA for controls.
01 | local plr = game.Players.LocalPlayer; |
04 | local debounce = false ; |
06 | local function IsKeyDown(keyCode) |
07 | local is_down = false ; |
08 | local keys = game:GetService( "UserInputService" ):GetKeysPressed(); |
09 | for i,v in pairs (keys) do |
10 | if v.KeyCode = = keyCode then |
20 | local local_limit = 0 ; |
23 | while IsKeyDown(key) do |
25 | plr.Character.Humanoid:ChangeState( |
26 | Enum.HumanoidStateType.Jumping); |
28 | local_limit = local_limit + 1 ; |
30 | if local_limit > = jump_limit then |
42 | game:GetService( "UserInputService" ).InputBegan:connect( function (input) |
45 | if input.KeyCode = = Enum.KeyCode.Space or |
46 | input.KeyCode = = Enum.KeyCode.ButtonA then |
Now how to actually get this script to work is a whole other story.
First, make sure that the script is a LocalScript inside some part of the client (Preferably the client's StarterPlayerScripts), Lastly you may have to disable or remove ROBLOX movement script(s), or use this as ROBLOX's movement script for all clients. (You can do so by naming the localscript "ControlScript" and placing it in StarterPlayerScripts) You may need to do this because of the fact that ROBLOX uses Enum.KeyCode.Space for jumping as well, and it will most likely not overlap smoothly, although you can always change the KeyCodes in InputBegan to a keycode that roblox does not use for movement.
Finally
If you do not want there to be a limit on how much a player can jump then simply remove lines 17, 20, 28, 30, 31, 32, and 33.
You can change how smooth the jump transitions are by changing the wait time on line 29.
You can also edit the jump limit to however many extra times you want the player to be able to jump.
I hope this helped you.