Making a custom fall animation

I changed it a bit. Changed it using tick() and delay and only using the humanoid:getstate of freefall only.

local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local hum = char:WaitForChild("Humanoid")

local animation = script:WaitForChild("laydown")
local animator = hum:WaitForChild("Animator")
local load = animator:LoadAnimation(animation)
load.Priority = Enum.AnimationPriority.Action
load.Looped = true

local delaytime = 0.5
local start -- create a variable with no value yet

hum.StateChanged:Connect(function(oldState,newState)
	if newState == Enum.HumanoidStateType.Freefall then
		start = tick() -- returns a current starting time value
		delay(delaytime,function()
			if tick() - start >= delaytime and hum:GetState() == Enum.HumanoidStateType.Freefall then
				load:Play()
			end
		end)
	elseif hum:GetState() ~= Enum.HumanoidStateType.Freefall then
		load:Stop()
	end
end)

2 Likes