Hi everyone,
I have run into an issue where the character is unable to jump while sprinting.
This is FULL code:
Summary
local BoostSpeed = 28
local NormalSpeed = 16
RunService.RenderStepped:Connect(function()
UIS.InputBegan:Connect(function(input, gameProcessed)
if not gameProcessed then
if input.KeyCode == Enum.KeyCode.LeftShift then
humanoid.WalkSpeed = BoostSpeed
if State == "onRunning" then
UIS.InputEnded:Connect(function(input, gameProcessed)
if not gameProcessed then
if input.KeyCode == Enum.KeyCode.Space then
humanoid:ChangeState(Enum.HumanoidStateType.Jumping)
wait()
humanoid.PlatformStand = true
end
end
end)
end
end
end
end)
UIS.InputEnded:Connect(function(input, gameProcessed)
if not gameProcessed then
if input.KeyCode == Enum.KeyCode.LeftShift then
humanoid.WalkSpeed = NormalSpeed
end
end
end)
end)
As you can see I have already tried to fix this issue by adding this section of code:
if State == "onRunning" then
UIS.InputEnded:Connect(function(input, gameProcessed)
if not gameProcessed then
if input.KeyCode == Enum.KeyCode.Space then
humanoid:ChangeState(Enum.HumanoidStateType.Jumping)
wait()
humanoid.PlatformStand = true
end
end
end)
end
I was able fix this issue by just adding the UIS.InputEnded
section and the code within it, however, the player was then able to infinitely jump. (Even if you stopped holding Shift, the player can still infinitely jump)
https://gyazo.com/11e4f6c4f278f9c61c4ad33c46fd5c5c
To try and fix that issue, I added the if State == "onRunning"
, which means that they are on the ground. Once I added, is was basically back to the original state where the character was unable to jump again.
^ I am using a system that made HumanoidStateType
basically non-existent, and have a completely remade StateTracker
that is working, that’s why I am checking if State
. All of my other movement mechanics work, including dashing, double jumping and charged jump, the only issue that I have left is being unable to jump while sprinting.