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

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

Asked by 4 years ago

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

Log in to vote
1
Answered by 4 years ago

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)
Ad
Log in to vote
0
Answered by 4 years ago

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.

Answer this question