Debounce and humanoidstatetype not working?

I was making a magic move where the player would send projectiles outwards to the mouse position. Everything went well until I got to the debounce. It worked at first as it should, but then later when I added HumanoidStateType.Jumping (to stop the player from using the move in the air or while jumping) it completely broke the script. The move is now spammable and there are absolutely no errors in the output. Any kind of help would be highly appreciated!

uis.InputBegan:Connect(function(input,processed)
if input.KeyCode == Enum.KeyCode.E and not processed then
local State = hum:GetState()
if deb2 == 1 then
local State = hum:GetState()
if State == Enum.HumanoidStateType.Jumping or State == Enum.HumanoidStateType.Freefall then return end
end
deb2 = 2
print(“Air!”)
Root.CFrame = CFrame.new(Root.Position, Root.Position + Mouse.Hit.LookVector)
event2:FireServer(plr)
anim3:Play()
wait(0.2)
CamShake:Shake(CameraShaker.Presets.Bump)
wait(cd2)
deb2 = 1
end
end)

Instead of return during the first denounce in free fall, set deb =2

Your finishing the function with return, so deb never equals 2

You’ll need another if statement to check when deb == 2

1 Like

it would be also helpful if you format your code using the backsticks, so its easier to read!

i tried :woman_shrugging: it doesnt detect it as valid code. theres nothing i can do lol

uis.InputBegan:Connect(function(input,processed)
if input.KeyCode == Enum.KeyCode.E and not processed then
local State = hum:GetState()
if deb2 == 1 then
local State = hum:GetState()
if State == Enum.HumanoidStateType.Jumping or State == Enum.HumanoidStateType.Freefall then return end
end
deb2 = 2
print(“Air!”)
Root.CFrame = CFrame.new(Root.Position, Root.Position + Mouse.Hit.LookVector)
event2:FireServer(plr)
anim3:Play()
wait(0.2)
CamShake:Shake(CameraShaker.Presets.Bump)
wait(cd2)
deb2 = 1
end
end)

the code formated

using ``` at start and end 30chars