Check if a player is falling

Hello Developers,

I have a question and am seeking for an answer. I need to know how to check if a player is not falling , as I am making an exploit detection system for my build system, so people don’t use exploits to fireserver so I check the distance the player is from the part requested to be built, if the player is further than the max, then they are exploiting. So it kicks them. An issue was players where reportedly getting kicked even after I added this to the code;

	local char = game.Workspace:FindFirstChild(plr.Name).HumanoidRootPart
	if char then
	if	not char.Parent.Humanoid:GetState() ~= Enum.HumanoidStateType.Freefall or not char.Parent.Humanoid:GetState() ~= Enum.HumanoidStateType.FallingDown or not char.Parent.Humanoid:GetState() ~= Enum.HumanoidStateType.Landed or not char.Parent.Humanoid:GetState() ~= Enum.HumanoidStateType.Flying then

So how would I check if they are not falling? I really need a solution. Thanks!

7 Likes
game.Players.PlayerAdded:Connect(function(plr)
	plr.CharacterAdded:Wait()
	plr.Character.Humanoid.StateChanged:Connect(function()
		if(plr.Character) then
			if(plr.Character.Humanoid:GetState() == Enum.HumanoidStateType.Freefall) then
				-- is falling = true
			else
				-- is falling = false
			end
		end		
	end)
end)

I made this script in studio that runs only when the state is changed, so it doesn’t lag

4 Likes

check if Humanoid.FloorMaterial is nil

6 Likes

Somehow this was the solution provided from @CraftDualMine but some things had to get adjusted, new code;

			if not (char.Parent.Humanoid:GetState() == Enum.HumanoidStateType.FallingDown) then
11 Likes