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)

3 comments
There is an infinite loop in here somewhere that crashed the playsolo. lol.
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.
I put "wait()"'s at the ends and it worked. Thanks!