-- Decompiled with the Synapse X Luau decompiler.

local l__Parent__1 = script.Parent.Parent;
local l__Humanoid__2 = l__Parent__1:WaitForChild("Humanoid");
local v3, v4 = pcall(function()
	return UserSettings():IsUserFeatureEnabled("UserNoUpdateOnLoop");
end);
local v5, v6 = pcall(function()
	return UserSettings():IsUserFeatureEnabled("UserEmoteToRunThresholdChange");
end);
local v7, v8 = pcall(function()
	return UserSettings():IsUserFeatureEnabled("UserPlayEmoteByIdAnimTrackReturn2");
end);
if not v7 then

end;
local l__ScaleDampeningPercent__9 = script:FindFirstChild("ScaleDampeningPercent");
math.randomseed(tick());
function findExistingAnimationInSet(p1, p2)
	if p1 ~= nil then
		if p2 == nil then
			return 0;
		end;
	else
		return 0;
	end;
	local l__count__10 = p1.count;
	local v11 = 1 - 1;
	while true do
		if p1[v11].anim.AnimationId == p2.AnimationId then
			return v11;
		end;
		if 0 <= 1 then
			if v11 < l__count__10 then

			else
				break;
			end;
		elseif l__count__10 < v11 then

		else
			break;
		end;
		v11 = v11 + 1;	
	end;
	return 0;
end;
local u1 = {};
local u2 = {};
function configureAnimationSet(p3, p4)
	if u1[p3] ~= nil then
		local v12, v13, v14 = pairs(u1[p3].connections);
		while true do
			local v15, v16 = v12(v13, v14);
			if v15 then

			else
				break;
			end;
			v14 = v15;
			v16:disconnect();		
		end;
	end;
	u1[p3] = {};
	u1[p3].count = 0;
	u1[p3].totalWeight = 0;
	u1[p3].connections = {};
	local u3 = true;
	local v17, v18 = pcall(function()
		u3 = game:GetService("StarterPlayer").AllowCustomAnimations;
	end);
	if not v17 then
		u3 = true;
	end;
	local v19 = script:FindFirstChild(p3);
	if u3 then
		if v19 ~= nil then
			table.insert(u1[p3].connections, v19.ChildAdded:connect(function(p5)
				configureAnimationSet(p3, p4);
			end));
			table.insert(u1[p3].connections, v19.ChildRemoved:connect(function(p6)
				configureAnimationSet(p3, p4);
			end));
			local v20, v21, v22 = pairs(v19:GetChildren());
			while true do
				local v23, v24 = v20(v21, v22);
				if v23 then

				else
					break;
				end;
				v22 = v23;
				if v24:IsA("Animation") then
					local v25 = 1;
					local l__Weight__26 = v24:FindFirstChild("Weight");
					if l__Weight__26 ~= nil then
						v25 = l__Weight__26.Value;
					end;
					u1[p3].count = u1[p3].count + 1;
					local l__count__27 = u1[p3].count;
					u1[p3][l__count__27] = {};
					u1[p3][l__count__27].anim = v24;
					u1[p3][l__count__27].weight = v25;
					u1[p3].totalWeight = u1[p3].totalWeight + u1[p3][l__count__27].weight;
					table.insert(u1[p3].connections, v24.Changed:connect(function(p7)
						configureAnimationSet(p3, p4);
					end));
					table.insert(u1[p3].connections, v24.ChildAdded:connect(function(p8)
						configureAnimationSet(p3, p4);
					end));
					table.insert(u1[p3].connections, v24.ChildRemoved:connect(function(p9)
						configureAnimationSet(p3, p4);
					end));
				end;			
			end;
		end;
	end;
	if u1[p3].count <= 0 then
		local v28, v29, v30 = pairs(p4);
		while true do
			local v31, v32 = v28(v29, v30);
			if v31 then

			else
				break;
			end;
			v30 = v31;
			u1[p3][v31] = {};
			u1[p3][v31].anim = Instance.new("Animation");
			u1[p3][v31].anim.Name = p3;
			u1[p3][v31].anim.AnimationId = v32.id;
			u1[p3][v31].weight = v32.weight;
			u1[p3].count = u1[p3].count + 1;
			u1[p3].totalWeight = u1[p3].totalWeight + v32.weight;		
		end;
	end;
	local v33, v34, v35 = pairs(u1);
	while true do
		local v36, v37 = v33(v34, v35);
		if v36 then

		else
			break;
		end;
		local l__count__38 = v37.count;
		local v39 = 1 - 1;
		while true do
			if u2[v37[v39].anim.AnimationId] == nil then
				l__Humanoid__2:LoadAnimation(v37[v39].anim);
				u2[v37[v39].anim.AnimationId] = true;
			end;
			if 0 <= 1 then
				if v39 < l__count__38 then

				else
					break;
				end;
			elseif l__count__38 < v39 then

			else
				break;
			end;
			v39 = v39 + 1;		
		end;	
	end;
end;
function configureAnimationSetOld(p10, p11)
	if u1[p10] ~= nil then
		local v40, v41, v42 = pairs(u1[p10].connections);
		while true do
			local v43, v44 = v40(v41, v42);
			if v43 then

			else
				break;
			end;
			v42 = v43;
			v44:disconnect();		
		end;
	end;
	u1[p10] = {};
	u1[p10].count = 0;
	u1[p10].totalWeight = 0;
	u1[p10].connections = {};
	local u4 = true;
	local v45, v46 = pcall(function()
		u4 = game:GetService("StarterPlayer").AllowCustomAnimations;
	end);
	if not v45 then
		u4 = true;
	end;
	local v47 = script:FindFirstChild(p10);
	if u4 then
		if v47 ~= nil then
			table.insert(u1[p10].connections, v47.ChildAdded:connect(function(p12)
				configureAnimationSet(p10, p11);
			end));
			table.insert(u1[p10].connections, v47.ChildRemoved:connect(function(p13)
				configureAnimationSet(p10, p11);
			end));
			local v48 = 1;
			local v49, v50, v51 = pairs(v47:GetChildren());
			while true do
				local v52, v53 = v49(v50, v51);
				if v52 then

				else
					break;
				end;
				v51 = v52;
				if v53:IsA("Animation") then
					table.insert(u1[p10].connections, v53.Changed:connect(function(p14)
						configureAnimationSet(p10, p11);
					end));
					u1[p10][v48] = {};
					u1[p10][v48].anim = v53;
					local l__Weight__54 = v53:FindFirstChild("Weight");
					if l__Weight__54 == nil then
						u1[p10][v48].weight = 1;
					else
						u1[p10][v48].weight = l__Weight__54.Value;
					end;
					u1[p10].count = u1[p10].count + 1;
					u1[p10].totalWeight = u1[p10].totalWeight + u1[p10][v48].weight;
					v48 = v48 + 1;
				end;			
			end;
		end;
	end;
	if u1[p10].count <= 0 then
		local v55, v56, v57 = pairs(p11);
		while true do
			local v58, v59 = v55(v56, v57);
			if v58 then

			else
				break;
			end;
			v57 = v58;
			u1[p10][v58] = {};
			u1[p10][v58].anim = Instance.new("Animation");
			u1[p10][v58].anim.Name = p10;
			u1[p10][v58].anim.AnimationId = v59.id;
			u1[p10][v58].weight = v59.weight;
			u1[p10].count = u1[p10].count + 1;
			u1[p10].totalWeight = u1[p10].totalWeight + v59.weight;		
		end;
	end;
	local v60, v61, v62 = pairs(u1);
	while true do
		local v63, v64 = v60(v61, v62);
		if v63 then

		else
			break;
		end;
		local l__count__65 = v64.count;
		local v66 = 1 - 1;
		while true do
			l__Humanoid__2:LoadAnimation(v64[v66].anim);
			if 0 <= 1 then
				if v66 < l__count__65 then

				else
					break;
				end;
			elseif l__count__65 < v66 then

			else
				break;
			end;
			v66 = v66 + 1;		
		end;	
	end;
end;
local u5 = {
	idle = { {
			id = "http://www.roblox.com/asset/?id=507766666", 
			weight = 1
		}, {
			id = "http://www.roblox.com/asset/?id=507766951", 
			weight = 1
		}, {
			id = "http://www.roblox.com/asset/?id=507766388", 
			weight = 9
		} }, 
	walk = { {
			id = "http://www.roblox.com/asset/?id=507777826", 
			weight = 10
		} }, 
	run = { {
			id = "http://www.roblox.com/asset/?id=507767714", 
			weight = 10
		} }, 
	swim = { {
			id = "http://www.roblox.com/asset/?id=507784897", 
			weight = 10
		} }, 
	swimidle = { {
			id = "http://www.roblox.com/asset/?id=507785072", 
			weight = 10
		} }, 
	jump = { {
			id = "http://www.roblox.com/asset/?id=507765000", 
			weight = 10
		} }, 
	fall = { {
			id = "http://www.roblox.com/asset/?id=507767968", 
			weight = 10
		} }, 
	climb = { {
			id = "http://www.roblox.com/asset/?id=507765644", 
			weight = 10
		} }, 
	sit = { {
			id = "http://www.roblox.com/asset/?id=2506281703", 
			weight = 10
		} }
};
function scriptChildModified(p15)
	local v67 = u5[p15.Name];
	if v67 ~= nil then
		configureAnimationSet(p15.Name, v67);
	end;
end;
script.ChildAdded:connect(scriptChildModified);
script.ChildRemoved:connect(scriptChildModified);
for v68, v69 in pairs(u5) do
	configureAnimationSet(v68, v69);
end;
local u6 = "";
local u7 = false;
local u8 = nil;
local u9 = nil;
local u10 = nil;
local u11 = nil;
local u12 = nil;
function stopAllAnimations()
	local v70 = u6;
	if u7 then
		v70 = "idle";
		u7 = false;
	end;
	u6 = "";
	u8 = nil;
	if u9 ~= nil then
		u9:disconnect();
	end;
	if u10 ~= nil then
		u10:Stop();
		u10:Destroy();
		u10 = nil;
	end;
	if u11 ~= nil then
		u11:disconnect();
	end;
	if u12 ~= nil then
		u12:Stop();
		u12:Destroy();
		u12 = nil;
	end;
	return v70;
end;
local u13 = l__ScaleDampeningPercent__9;
function getHeightScale()
	if l__Humanoid__2 then

	else
		return 1;
	end;
	if not l__Humanoid__2.AutomaticScalingEnabled then
		return 1;
	end;
	local v71 = l__Humanoid__2.HipHeight / 2;
	if u13 == nil then
		u13 = script:FindFirstChild("ScaleDampeningPercent");
	end;
	if u13 ~= nil then
		v71 = 1 + (l__Humanoid__2.HipHeight - 2) * u13.Value / 2;
	end;
	return v71;
end;
local function u14(p16)
	return p16 * 1.25 / getHeightScale();
end;
local function u15(p17)
	local v72 = u14(p17);
	local v73 = 0.0001;
	local v74 = 0.0001;
	local v75 = v72 / 0.5;
	local v76 = v72 / 1;
	if v72 <= 0.5 then
		v73 = 1;
	elseif v72 < 1 then
		local v77 = (v72 - 0.5) / 0.5;
		v73 = 1 - v77;
		v74 = v77;
		v75 = 1;
		v76 = 1;
	else
		v74 = 1;
	end;
	u10:AdjustWeight(v73);
	u12:AdjustWeight(v74);
	u10:AdjustSpeed(v75);
	u12:AdjustSpeed(v76);
end;
local u16 = 1;
function setAnimationSpeed(p18)
	if u6 == "walk" then
		u15(p18);
		return;
	end;
	if p18 ~= u16 then
		u16 = p18;
		u10:AdjustSpeed(u16);
	end;
end;
local u17 = v3 or v4;
function keyFrameReachedFunc(p19)
	if p19 == "End" then
		if u6 == "walk" then
			if u17 == true then

			else
				u12.TimePosition = 0;
				u10.TimePosition = 0;
				return;
			end;
			if u12.Looped ~= true then
				u12.TimePosition = 0;
			end;
			if u10.Looped ~= true then
				u10.TimePosition = 0;
				return;
			end;
		else
			local v78 = u6;
			if u7 then
				if u10.Looped then
					return;
				end;
				v78 = "idle";
				u7 = false;
			end;
			playAnimation(v78, 0.15, l__Humanoid__2);
			setAnimationSpeed(u16);
		end;
	end;
end;
function rollAnimation(p20)
	local v79 = math.random(1, u1[p20].totalWeight);
	local v80 = 1;
	while true do
		if u1[p20][v80].weight < v79 then

		else
			break;
		end;
		v79 = v79 - u1[p20][v80].weight;
		v80 = v80 + 1;	
	end;
	return v80;
end;
local function u18(p21, p22, p23, p24)
	if p21 ~= u8 then
		if u10 ~= nil then
			u10:Stop(p23);
			u10:Destroy();
		end;
		if u12 ~= nil then
			u12:Stop(p23);
			u12:Destroy();
			if u17 == true then
				u12 = nil;
			end;
		end;
		u16 = 1;
		u10 = p24:LoadAnimation(p21);
		u10.Priority = Enum.AnimationPriority.Core;
		u10:Play(p23);
		u6 = p22;
		u8 = p21;
		if u9 ~= nil then
			u9:disconnect();
		end;
		u9 = u10.KeyframeReached:connect(keyFrameReachedFunc);
		if p22 == "walk" then
			u12 = p24:LoadAnimation(u1.run[rollAnimation("run")].anim);
			u12.Priority = Enum.AnimationPriority.Core;
			u12:Play(p23);
			if u11 ~= nil then
				u11:disconnect();
			end;
			u11 = u12.KeyframeReached:connect(keyFrameReachedFunc);
		end;
	end;
end;
function playAnimation(p25, p26, p27)
	u18(u1[p25][rollAnimation(p25)].anim, p25, p26, p27);
	u7 = false;
end;
function playEmote(p28, p29, p30)
	u18(p28, p28.Name, p29, p30);
	u7 = true;
end;
local u19 = v5 or v6;
local u20 = "Standing";
function onRunning(p31)
	local v81 = u19;
	if v81 then
		v81 = u7 and l__Humanoid__2.MoveDirection == Vector3.new(0, 0, 0);
	end;
	if (v81 and l__Humanoid__2.WalkSpeed or 0.75) < p31 then
		playAnimation("walk", 0.2, l__Humanoid__2);
		setAnimationSpeed(p31 / 16);
		u20 = "Running";
		return;
	end;
	if not u7 then
		playAnimation("idle", 0.2, l__Humanoid__2);
		u20 = "Standing";
	end;
end;
function onDied()
	u20 = "Dead";
end;
local u21 = 0;
function onJumping()
	playAnimation("jump", 0.1, l__Humanoid__2);
	u21 = 0.31;
	u20 = "Jumping";
end;
function onClimbing(p32)
	playAnimation("climb", 0.1, l__Humanoid__2);
	setAnimationSpeed(p32 / 5);
	u20 = "Climbing";
end;
function onGettingUp()
	u20 = "GettingUp";
end;
function onFreeFall()
	if u21 <= 0 then
		playAnimation("fall", 0.2, l__Humanoid__2);
	end;
	u20 = "FreeFall";
end;
function onFallingDown()
	u20 = "FallingDown";
end;
function onSeated()
	u20 = "Seated";
end;
function onPlatformStanding()
	u20 = "PlatformStanding";
end;
function onSwimming(p33)
	if 1 < p33 then

	else
		playAnimation("swimidle", 0.4, l__Humanoid__2);
		u20 = "Standing";
		return;
	end;
	playAnimation("swim", 0.4, l__Humanoid__2);
	setAnimationSpeed(p33 / 10);
	u20 = "Swimming";
end;
local u22 = 0;
function stepAnimate(p34)
	u22 = p34;
	if 0 < u21 then
		u21 = u21 - (p34 - u22);
	end;
	if u20 == "FreeFall" then
		if u21 <= 0 then
			playAnimation("fall", 0.2, l__Humanoid__2);
			return;
		end;
	end;
	if u20 == "Seated" then
		playAnimation("sit", 0.5, l__Humanoid__2);
		return;
	end;
	if u20 == "Running" then
		playAnimation("walk", 0.2, l__Humanoid__2);
		return;
	end;
	if u20 ~= "Dead" then
		if u20 ~= "GettingUp" then
			if u20 ~= "FallingDown" then
				if u20 ~= "Seated" then
					if u20 == "PlatformStanding" then
						stopAllAnimations();
					end;
				else
					stopAllAnimations();
				end;
			else
				stopAllAnimations();
			end;
		else
			stopAllAnimations();
		end;
	else
		stopAllAnimations();
	end;
end;
l__Humanoid__2.Died:connect(onDied);
l__Humanoid__2.Running:connect(onRunning);
l__Humanoid__2.Jumping:connect(onJumping);
l__Humanoid__2.Climbing:connect(onClimbing);
l__Humanoid__2.GettingUp:connect(onGettingUp);
l__Humanoid__2.FreeFalling:connect(onFreeFall);
l__Humanoid__2.FallingDown:connect(onFallingDown);
l__Humanoid__2.Seated:connect(onSeated);
l__Humanoid__2.PlatformStanding:connect(onPlatformStanding);
l__Humanoid__2.Swimming:connect(onSwimming);
if l__Parent__1.Parent ~= nil then
	playAnimation("idle", 0.1, l__Humanoid__2);
	u20 = "Standing";
end;
while l__Parent__1.Parent ~= nil do
	local v82, v83 = wait(0.1);
	stepAnimate(v83);
end;