local I=script.Parent.Parent local h=I:WaitForChild("\072\117\109\097\110\111\105\100")local w={}for I,u in pairs((I:WaitForChild("\065\110\105\109\097\116\105\111\110\115")):GetChildren())do w[u.Name]=h:LoadAnimation(u)end local u="\078\111\110\101"local function i()local h=Ray.new(I.HumanoidRootPart.Position+Vector3.new(0,-4.3,0),Vector3.new(0,-1,0))local w,u=game.Workspace:FindPartOnRay(h,I)if w and w.CanCollide then return true else return false end end local function J()for I,h in pairs(w)do h:Stop()end end local function R(I)if u~=I then J()u=I if w[u]then w[u]:Play()end end end while true do(game:GetService("\082\117\110\083\101\114\118\105\099\101")).Stepped:wait()if h.Health>0 then if i()then local h=(Vector3.new(I.HumanoidRootPart.Velocity.X,0,I.HumanoidRootPart.Velocity.Z)).magnitude if h>1 then R("\087\097\108\107")else R("\073\100\108\101")end else local h=I.HumanoidRootPart.Velocity.Y if h>0 then R("\074\117\109\112")else R("\070\097\108\108")end end else R("\068\101\097\100")end end
--Scripted by DermonDarble

local character = script.Parent.Parent
local humanoid = character:WaitForChild("Humanoid")
local animations = {}

for i, animation in pairs(character:WaitForChild("Animations"):GetChildren()) do
	animations[animation.Name] = humanoid:LoadAnimation(animation)
end

local state = "None"

local function Grounded()
	local ray = Ray.new(character.HumanoidRootPart.Position + Vector3.new(0, -4.3, 0), Vector3.new(0, -1, 0))
	local hit, position = game.Workspace:FindPartOnRay(ray, character)
	if hit and hit.CanCollide then
		return true
	else
		return false
	end
end

local function StopAll()
	for i, animation in pairs(animations) do
		animation:Stop()
	end
end

local function ChangeState(newState)
	if state ~= newState then
		StopAll()
		state = newState
		if animations[state] then
			animations[state]:Play()
		end
	end
end

while true do
	game:GetService("RunService").Stepped:wait()
	if humanoid.Health > 0 then
		if Grounded() then
			local speed =
				Vector3.new(character.HumanoidRootPart.Velocity.X, 0, character.HumanoidRootPart.Velocity.Z).magnitude
			if speed > 1 then
				ChangeState("Walk")
			else
				ChangeState("Idle")
			end
		else
			local ySpeed = character.HumanoidRootPart.Velocity.Y
			if ySpeed > 0 then
				ChangeState("Jump")
			else
				ChangeState("Fall")
			end
		end
	else
		ChangeState("Dead")
	end
end
