I tried to make a double jump script but it did not work this is the script and the error on output
local character = script.Parent
local humanoid = character:WaitForChild("Humanoid")
local uis = game:GetService("UserInputService")
local canDoubleJump = false
local hasLanded = true
humanoid.StateChanged:Connect(function(previous, new)
if new == Enum.HumanoidStateType.Jumping and hasLanded then
if not canDoubleJump then canDoubleJump = true; hasLanded = false end
elseif new == Enum.HumanoidStateType.Landed then
canDoubleJump = false
hasLanded = true
end
end)
uis.InputBegan:Connect(function(input, processed)
if processed then return end
if input.Keycode == Enum.KeyCode.Space then
if canDoubleJump then
humanoid:ChangeState(Enum.HumanoidStateType.Jumping)
canDoubleJump = false
end
end
end)
local players = game:GetService("Players")
local player = players.Player or players.PlayerAdded:wait()
local character = player.Character or player.CharacterAdded:wait()
local humanoid = character:WaitForChild("Humanoid")
local uis = game:GetService("UserInputService")
local canDoubleJump = false
local hasLanded = true
humanoid.StateChanged:Connect(function(previous, new)
if new == Enum.HumanoidStateType.Jumping and hasLanded then
if not canDoubleJump then canDoubleJump = true; hasLanded = false end
elseif new == Enum.HumanoidStateType.Landed then
canDoubleJump = false
hasLanded = true
end
end)
uis.InputBegan:Connect(function(input, processed
if processed then return end
if input.Keycode == Enum.KeyCode.Space then
if canDoubleJump then
humanoid:ChangeState(Enum.HumanoidStateType.Jumping)
canDoubleJump = false
end
end
end)
Jump request are actually already bound.
I believe getting rid of this
if processed then return end
Will fix your problem. Since the all taps of the spacebar are counted as jump requested they are always processed. (unless you unbind them or give the input a higher priority)
Alternatively, you can just copy the code from this tutorial. If you follow through you will see that they used a different event too.