function onDied()stopLoopedSounds()for l,w in pairs((Figure:FindFirstChild("\072\101\097\100")):GetChildren())do if w and w.ClassName=="\083\111\117\110\100"then w.Volume=0 w:Stop()end end sDied.Volume=1 sDied:Play()end local l=0 local w=0 function onStateFall(Z,M)l=l+1 if Z then M.Volume=0 M:Play()task.spawn(function()local w=0 local Z=l while w<1.5 and l==Z do local l=math.max(w-.3,0)M.Volume=l task.wait(.1)w=w+.1 end end)else M:Stop()end w=math.max(w,math.abs(Head.Velocity.Y))end function onStateNoStop(l,w)if l then w:Play()end end function onRunning(l)sClimbing:Stop()sSwimming:Stop()if prevState=="\070\114\101\101\070\097\108\108"and w>.1 then local l=math.min(1.0,math.max(.0,(w-50)/110))sLanding.Volume=l sLanding:Play()w=0 end if l>.5 then sRunning:Play()sRunning.Pitch=l/8.0 else sRunning:Stop()end prevState="\082\117\110"end function onSwimming(l)if prevState~="\083\119\105\109"and l>.1 then local w=math.min(1.0,l/350)sSplash.Volume=w sSplash:Play()prevState="\083\119\105\109"end sClimbing:Stop()sRunning:Stop()sSwimming.Pitch=1.6 sSwimming:Play()end function onClimbing(l)sRunning:Stop()sSwimming:Stop()if l>.01 then sClimbing:Play()sClimbing.Pitch=l/5.5 else sClimbing:Stop()end prevState="\067\108\105\109\098"end


function onDied()
stopLoopedSounds()
for _,Child in pairs(Figure:FindFirstChild("Head"):GetChildren())do
if Child and Child.ClassName=="Sound"then
Child.Volume=0
Child:Stop()
end
end
sDied.Volume=1;
sDied:Play();
end

local fallCount = 0
local fallSpeed = 0
function onStateFall(state, sound)
fallCount = fallCount + 1
if state then
sound.Volume = 0
sound:Play()
task.spawn( function()
local t = 0
local thisFall = fallCount
while t < 1.5 and fallCount == thisFall do
local vol = math.max(t - 0.3 , 0)
sound.Volume = vol
task.wait(0.1)
t = t + 0.1
end
end)
else
sound:Stop()
end
fallSpeed = math.max(fallSpeed, math.abs(Head.Velocity.Y))
end


function onStateNoStop(state, sound)
if state then
sound:Play()
end
end


function onRunning(speed)
sClimbing:Stop()
sSwimming:Stop()
if (prevState == "FreeFall" and fallSpeed > 0.1) then
local vol = math.min(1.0, math.max(0.0, (fallSpeed - 50) / 110))
sLanding.Volume = vol
sLanding:Play()
fallSpeed = 0
end
if speed>0.5 then
sRunning:Play()
sRunning.Pitch = speed / 8.0
else
sRunning:Stop()
end
prevState = "Run"
end

function onSwimming(speed)
if (prevState ~= "Swim" and speed > 0.1) then
local volume = math.min(1.0, speed / 350)
sSplash.Volume = volume
sSplash:Play()
prevState = "Swim"
end
sClimbing:Stop()
sRunning:Stop()
sSwimming.Pitch = 1.6
sSwimming:Play()
end

function onClimbing(speed)
sRunning:Stop()
sSwimming:Stop()
if speed>0.01 then
sClimbing:Play()
sClimbing.Pitch = speed / 5.5
else
sClimbing:Stop()
end
prevState = "Climb"
end