Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Trying to make a bool value return false if player is on the ground and vice versa?

Asked by
hudzell 238 Moderation Voter
10 years ago

As the title says, I am trying to make a bool value return false if player is on the ground and vice versa. How would I do such? I haven't really tried anything because, well, I haven't the slightest clue how! Here's my current code:

while true do
    wait()

end

(yes the code was a joke)

1 answer

Log in to vote
0
Answered by
BlackJPI 2658 Snack Break Moderation Voter Community Moderator
10 years ago

Instead of trying to detect if the player is on the ground, it is much easier to detect when the player is not on the ground. Thus when the player is not falling, the player must be on the ground!

local humanoid = game.Workspace.Player1.Humanoid -- Location of Humanoid
local offground = false

humanoid.FreeFalling:connect(function(falling)
    offground = true
    repeat wait() until not falling
    offground = false
end)

You may also want to check if the humanoid triggers some other events such as Climbing or Jumping in order to fit you needs. (More info on humanoid events here).

Ad

Answer this question