I want to add a denounce to the space bar when the player jumps, and disable it temporarily. The problem is, I don't know how to do this. Here is my failed attempt.
01 | local character = script.Parent |
02 |
03 | local JUMP_DEBOUNCE = 5 |
04 |
05 | local humanoid = character:WaitForChild( "Humanoid" ) |
06 |
07 | local isJumping = false |
08 | humanoid.StateChanged:Connect( function (oldState, newState) |
09 | if newState = = Enum.HumanoidStateType.Jumping then |
10 | if not isJumping then |
11 | isJumping = true |
12 | humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping and Enum.KeyCode.Space, false ) |
13 | end |
14 | elseif newState = = Enum.HumanoidStateType.Landed then |
15 | if isJumping then |
01 | -- Variables -- |
02 | local character = script.Parent |
03 | local humanoid = character:WaitForChild( "Humanoid" ) |
04 | local isJumping = false |
05 | local UserInputService = game:GetService( "UserInputService" ) |
06 | local DisablingJumpingTime = 5 |
07 |
08 | -- Script -- |
09 |
10 | humanoid.StateChanged:Connect( function (oldState, newState) |
11 | if newState = = Enum.HumanoidStateType.Jumping then |
12 | if not isJumping then |
13 | isJumping = true |
14 | wait() -- dont know why, but this wait() fixes it |
15 | humanoid.JumpPower = 0 -- Instead of disabling the jumping, you can change the JumpPower to 0 instead! |