Hello!
I have a problem with my script. For some reason it does not detect when I stop jumping. Any help?
local char = game.Players.LocalPlayer.Character
local hum = char:WaitForChild("Humanoid")
jump = false
hum.StateChanged:Connect(function(oldState, newState)
if newState == Enum.HumanoidStateType.Jumping then -- if humanoid is currently jumping
jump = true
print("hi")
end
end)
RunService.RenderStepped:Connect(function()
wait(0.1)
if jump == true then
if char.Humanoid:GetState(Enum.HumanoidStateType.Jumping) then
else
print("bye")
jump = false
end
end
end)
The main problem with the script is that it is not checking if the player is currently in the air before setting the “jump” variable to “true”. This means that if the player jumps and then immediately lands, the “jump” variable will still be set to “true”.
To fix this, you can add a check to see if the player is in the air before setting the “jump” variable to “true”:
if newState == Enum.HumanoidStateType.Jumping and not char.Humanoid:GetState(Enum.HumanoidStateType.Jumping) then
jump = true
print("hi")
end