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

Trying to find a way to use humanoid state types to find out when a player lands?

I've attempted it for hours but can't figure it out. This is one of my many attempts, obviously its wrong. Just trying to find a way.

local newstate = player.Character.Humanoid:GetState()
while newstate == 0 do
	newstate = player.Character.Humanoid:GetState()
	if newstate == 7 then
		player.Character.UpperTorso.Trail.Enabled = false
		player.Character.LowerTorso.Trail.Enabled = false
		player.Character.Head.Trail.Enabled = false
		player.Character.LeftUpperArm.Trail.Enabled = false
		player.Character.LeftLowerArm.Trail.Enabled = false
		player.Character.LeftHand.Trail.Enabled = false
		player.Character.LeftUpperLeg.Trail.Enabled = false
		player.Character.LeftLowerLeg.Trail.Enabled = false
		player.Character.LeftFoot.Trail.Enabled = false
		player.Character.RightUpperArm.Trail.Enabled = false
		player.Character.RightLowerArm.Trail.Enabled = false
		player.Character.RightHand.Trail.Enabled = false
		player.Character.RightUpperLeg.Trail.Enabled = false
		player.Character.RightLowerLeg.Trail.Enabled = false
		player.Character.RightFoot.Trail.Enabled = false
		print'Hit Ground'
	end
end

Any form of help towards this, even just a hint would be greatly appreciated

2 answers

just use the Humanoid.StateChanged event..

local Humanoid = --the humanoid;
Humanoid.StateChanged:Connect(function(oldState, newState)
	if(newState == enum.HumanoidStateType.Landed) then
		print("player just landed!")
	end
end)

I figured out how to do this, very sorry again for answering my own question!

In While Statements do Humanoid:GetState() ~= Enum.HumanoidStateType.Landed In If Statements do Humanoid:GetState() == Enum.HumanoidStateType.Landed

It might work the other way around to, but this solved my problem.

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