Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

[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)

01local UserInputService = game:GetService("UserInputService")
02local lastjumptick = tick()
03local Jumped = 1
04local hum = game.Players.LocalPlayer.Character:WaitForChild('Humanoid')
05local anim = hum:LoadAnimation(script.Parent.Flip)
06 
07local Camera = workspace.CurrentCamera
08 
09 
10local function onInputBegan(input,gameProcessed)
11    if input.UserInputType == Enum.UserInputType.Keyboard then
12        local keyPressed = input.KeyCode
13        if keyPressed == Enum.KeyCode.Space then
14            if Jumped == 1 then
15                Jumped = 2
View all 43 lines...

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!

0
But, if it's only in a local script only you would be able to see yourself using double jump, everyone else wouldn't see it. broham896 54 — 5y

1 answer

Log in to vote
1
Answered by 5 years ago

Use debounce, you just make a variable like locla debounce = false When you do the double jump set debounce to true, and make it so if debounce is true you cannot double jump, wait whatever the cooldown is going to be and set debounce to false again. If debounce is false make sure they are able to double jump.

0
local* broham896 54 — 5y
0
@broham896 Okay, I'll try. Sensei_Developer 298 — 5y
Ad

Answer this question