What do I want to achieve?
I’m trying to make a simple double jump system where you can jump twice and at the 2nd/last jump, you can no longer jump and automatically fall.
Issue?
The jumps are infinite and have no limit. I don’t know how to limit or stop the player from jumping an excessive amount of times.
What did I try to fix this?
I tried to use and mess with hum.StateChanged to control whenever the state of humanoid was changed. I’ve moved around values but it’s all ended to the same conclusion which is an infinite amount of jumps.
Why do I think this is?
I think this is happening because the function is automatically reassigning it’s state to jumping.
Local script in the StarterGui:
local UIS = game:GetService("UserInputService")
local plr = game.Players.LocalPlayer
local hum = plr.Character.Humanoid
local maxjumps = 3
local startjumps = 0
local debounce = false
UIS.InputBegan:Connect(function(input, GPE)
if input.KeyCode == Enum.KeyCode.Space then
startjumps = startjumps + 1
hum:ChangeState(Enum.HumanoidStateType.Jumping)
print(startjumps)
if startjumps == maxjumps then
startjumps = 0
hum:ChangeState(Enum.HumanoidStateType.Landed)
end
end
end)