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

How to detect if a player has fallen down?

Asked by
uJordy 4
7 years ago
Edited 7 years ago
local Humanoid = game.Workspace:WaitForChild("Red Nosed Seal").Humanoid
Humanoid.StateChanged:connect(function(old,new)
    print(old .. "    " .. new)
    if new == (1) then -- (A)
         --code
        Humanoid.Jump = true
    end
end)

Some help?

I've tried this but it gives the error of this http://prntscr.com/gf2xcp

1
format your code PyccknnXakep 1225 — 7y
0
Done uJordy 4 — 7y

1 answer

Log in to vote
1
Answered by 7 years ago
Edited 7 years ago

You would use the Enum HumanoidStateType followed by GetState(), as described here and here. Example:

local h = script.Parent:FindFirstChildOfClass("Humanoid") --wherever the humanoid is
    if h:GetState() == Enum.HumanoidStateType.Freefall then --if its falling
        print("Falling") --print falling
    end

or

local h = script.Parent:FindFirstChildOfClass("Humanoid")
    h.StateChanged:Connect(function(state)
        if state == Enum.HumanoidStateType.Freefall then
        print("Falling")
    end
    end)

This was written from scratch so I apologize if this didn't work. Please accept my answer if this helped!

0
Trying it now, I'll let you know how it goes uJordy 4 — 7y
0
Works, Thank you uJordy 4 — 7y
0
No problem PyccknnXakep 1225 — 7y
Ad

Answer this question