Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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

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).

This discussion is preserved as it was. New answers, comments, and votes are closed.