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

Stops working/Takes longer to receive input?

Asked by
drahsid5 250 Moderation Voter
10 years ago

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

Log in to vote
1
Answered by
Azarth 3141 Moderation Voter Community Moderator
10 years ago
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)
0
There is an infinite loop in here somewhere that crashed the playsolo. lol. drahsid5 250 — 10y
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. Azarth 3141 — 10y
0
I put "wait()"'s at the ends and it worked. Thanks! drahsid5 250 — 10y
Ad

Answer this question