Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Stops working/Takes longer to receive input?

Hi, I'm making a double-jump script, and it seems to work fine- for the first jump-or-so. then it takes longer to preform the second jump, make the second jump trigger randomly, etc. I think it has something to do with the "jump" variable.

This seems to stop working, or at lest take longer to do the function, can anyone tell me how to fix it?

repeat wait(0.25) until game.Players.LocalPlayer
local Plr = game.Players.LocalPlayer
local Mouse = Plr:GetMouse()
local Character = Plr.Character
jump = 0
Character.Humanoid.Jumping:connect(function(jumping)
Character.Humanoid.FreeFalling:connect(function(fall)
Mouse.KeyDown:connect(function(Key)
repeat wait() until fall == false and jumping == false and jump == 0 or Key:byte() == 32 and fall == true and jump ~= 2
if Key:byte() == 32 and fall == true or jump == true and jump ~= 2 then
Character.Torso.Velocity = (Vector3.new(0,55,0))
jump = 2
Key = nil
wait(3)
if jump == 2 or jump == 1 then jump = 0 end
elseif falling == true and jumping == false then
jump = 1
elseif fall == false and jumping == false then
jump = 0
Key = nil

Key = nil
end 
end)
end)
end)

1 answer

✓ Accepted answer
repeat wait() until game.Players.LocalPlayer
local db = true
local down = false
local p = game.Players.LocalPlayer


local firstClick = 0 
local db = true

p:GetMouse().KeyDown:connect(function(key)
    if key:byte() == 32 and db then
        if firstClick == 0 then
            firstClick = tick()
        elseif firstClick ~= 0 then
            calc = (tick() - firstClick)
            print(calc)
            firstClick = 0 
            if calc <= .16 then
                db = false
                p.Character.Torso.Velocity = p.Character.Torso.Velocity + Vector3.new(0,50,0)
                wait(1.3)
                db = true
            end
        end
    end
end)

3 comments

0

There is an infinite loop in here somewhere that crashed the playsolo. lol.

0

repeat wait() until game.Players.LocalPlayer --Maybe you didn't put it in a LocalScript? Event then, that wouldn't cause a crash. Maybe you have another script causing it.

0

I put "wait()"'s at the ends and it worked. Thanks!

This discussion is preserved as it was. New answers, comments, and votes are closed.