[SOLVED] How do I prevent the player from spamming double-jump to reach unlimited height?
Asked by
5 years ago Edited 5 years ago
I found this double-jump script online and I tested it: (LocalScript in PlayerGui)
01 | local UserInputService = game:GetService( "UserInputService" ) |
02 | local lastjumptick = tick() |
04 | local hum = game.Players.LocalPlayer.Character:WaitForChild( 'Humanoid' ) |
05 | local anim = hum:LoadAnimation(script.Parent.Flip) |
07 | local Camera = workspace.CurrentCamera |
10 | local function onInputBegan(input,gameProcessed) |
11 | if input.UserInputType = = Enum.UserInputType.Keyboard then |
12 | local keyPressed = input.KeyCode |
13 | if keyPressed = = Enum.KeyCode.Space then |
17 | if Jumped = = 2 and tick() - lastjumptick < = . 5 then |
19 | local JumpBrick = Instance.new( "Part" ,workspace) |
20 | JumpBrick.CFrame = game.Players.LocalPlayer.Character.HumanoidRootPart.CFrame * CFrame.new( 0 ,- 2 , 0 ) |
21 | JumpBrick.Size = Vector 3. new( 2 ,. 2 , 2 ) |
22 | JumpBrick.Anchored = true |
23 | JumpBrick.Transparency = 1 |
24 | game.Players.LocalPlayer.Character.Humanoid.JumpPower = 60 |
25 | game.Debris:AddItem(JumpBrick,. 5 ) |
27 | game.Players.LocalPlayer.Character.Humanoid.JumpPower = 50 |
37 | UserInputService.InputBegan:connect(onInputBegan) |
39 | UserInputService.InputBegan:Connect( function (keyCode) |
40 | if keyCode.keyCode = = Enum.KeyCode.Space then |
I know it's confusing and all, but I really need a solution, as my game is about to be released.
There is no errors in the output, and if I spam the SpaceBar
, (I made my game PC only) the player would infinitely jump to unlimited height.
Please help!