Hello, again!
This time, I want to know on how I can accurately get and print when a player jumps or when a player lands on the floor.
I have tried to do something like this with bool-values, but it is like every time you hold the jump button on your computer, the bool-values stay frozen.
I will try to explain and show about what I am talking about to the best of my ability, so prepare for your mind to be taken out of this world.
So, here is a video of me jumping:
robloxapp-20221230-2039560.wmv (3.0 MB)
On the dev console, the states that are being printed and they are pretty accurate according to the game.
Now, if I use a bool-values instead, here is what happens: [twist]
If I start to hold space to jump, the bool-value’s value for jumping becomes stuck on true, as-well as the bool-value’s value for checking when a player is on the ground, it gets stuck on false.
What I am trying to say is that I want a script that can detect when a player actually jumps and when a player actually hits the ground with bool-values.
Here is the script that “accurately” detects when a player jumps and hits the ground.
local char = script.Parent
local humanoid = char:FindFirstChild("Humanoid")
local onGround = script:WaitForChild("OnGround")
local Jumping = script:WaitForChild("Jumping")
humanoid.StateChanged:Connect(function(old, newstate)
if newstate == Enum.HumanoidStateType.Jumping and Jumping.Value == false and onGround.Value == true then
Jumping.Value = true
onGround.Value = false
print("jump")
end
end)
humanoid.StateChanged:Connect(function(old, newstate)
if newstate == Enum.HumanoidStateType.Landed and Jumping.Value == true and onGround.Value == false then
Jumping.Value = false
onGround.Value = true
print("ground")
end
end)
I need some help on this, it is okay if there is no solution whatsoever because this seems very difficult to try and resolve. Any help is appreciated.