<roblox xmlns:xmime="http://www.w3.org/2005/05/xmlmime" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://www.roblox.com/roblox.xsd" version="4">
	<External>null</External>
	<External>nil</External>
	<Item class="Script" referent="RBX0">
		<Properties>
			<bool name="Disabled">false</bool>
			<Content name="LinkedSource"><null></null></Content>
			<string name="Name">Animate</string>
			<string name="Source">-- Now with exciting TeamColors HACK!

function waitForChild(parent, childName)
	while true do
		local child = parent:findFirstChild(childName)
		if child then
			return child
		end
		parent.ChildAdded:wait()
	end
end


----------------------------- TEAM COLORS


function onTeamChanged(player)

	wait(1)

	local char = player.Character
	if char == nil then return end

	if (player.Neutral == true) then 
		-- Replacing the current BodyColor object will force a reset
		local old = char:findFirstChild(&quot;Body Colors&quot;)
		if (old == nil) then return end
		old:clone().Parent = char
		old.Parent = nil
	else
		local head = char:findFirstChild(&quot;Head&quot;)
		local torso = char:findFirstChild(&quot;Torso&quot;) 
		local left_arm = char:findFirstChild(&quot;Left Arm&quot;) 
		local right_arm = char:findFirstChild(&quot;Right Arm&quot;) 
		local left_leg = char:findFirstChild(&quot;Left Leg&quot;) 
		local right_leg = char:findFirstChild(&quot;Right Leg&quot;) 

		if head ~= nil then head.BrickColor = BrickColor.new(24) end
		if torso ~= nil then torso.BrickColor = player.TeamColor end
		if left_arm ~= nil then left_arm.BrickColor = BrickColor.new(26) end
		if right_arm ~= nil then right_arm.BrickColor = BrickColor.new(26) end
		if left_leg ~= nil then left_leg.BrickColor = BrickColor.new(26) end
		if right_leg ~= nil then right_leg.BrickColor = BrickColor.new(26) end
	end

	

end

function onPlayerPropChanged(property, player)
	if property == &quot;Character&quot; then
		onTeamChanged(player)
	end
	if property== &quot;TeamColor&quot; or property == &quot;Neutral&quot; then
		onTeamChanged(player)
	end
end


local cPlayer = game.Players:GetPlayerFromCharacter(script.Parent)
cPlayer.Changed:connect(function(property) onPlayerPropChanged(property, cPlayer) end )
onTeamChanged(cPlayer)


----------------------------- ANIMATION

-- declarations

local Figure = script.Parent
local Torso = waitForChild(Figure, &quot;Torso&quot;)
local RightShoulder = waitForChild(Torso, &quot;Right Shoulder&quot;)
local LeftShoulder = waitForChild(Torso, &quot;Left Shoulder&quot;)
local RightHip = waitForChild(Torso, &quot;Right Hip&quot;)
local LeftHip = waitForChild(Torso, &quot;Left Hip&quot;)
local Neck = waitForChild(Torso, &quot;Neck&quot;)
local Humanoid = waitForChild(Figure, &quot;Humanoid&quot;)
local pose = &quot;Standing&quot;

local toolAnim = &quot;None&quot;
local toolAnimTime = 0

local isSeated = false

-- functions

function onRunning(speed)
	if isSeated then return end

	if speed&gt;0 then
		pose = &quot;Running&quot;
	else
		pose = &quot;Standing&quot;
	end
end

function onDied()
	pose = &quot;Dead&quot;
end

function onJumping()
	isSeated = false
	pose = &quot;Jumping&quot;
end

function onClimbing()
	pose = &quot;Climbing&quot;
end

function onGettingUp()
	pose = &quot;GettingUp&quot;
end

function onFreeFall()
	pose = &quot;FreeFall&quot;
end

function onFallingDown()
	pose = &quot;FallingDown&quot;
end

function onSeated()
	isSeated = true
	pose = &quot;Seated&quot;
	print(&quot;Seated&quot;)
end



function moveJump()
	RightShoulder.MaxVelocity = 0.5
	LeftShoulder.MaxVelocity = 0.5
	RightShoulder.DesiredAngle = 3.14
	LeftShoulder.DesiredAngle = -3.14
	RightHip.DesiredAngle = 0
	LeftHip.DesiredAngle = 0
end

function moveFreeFall()
	RightShoulder.MaxVelocity = 0.5
	LeftShoulder.MaxVelocity = 0.5
	RightShoulder.DesiredAngle = 1
	LeftShoulder.DesiredAngle = -1
	RightHip.DesiredAngle = 0
	LeftHip.DesiredAngle = 0
end


function moveClimb()
	RightShoulder.MaxVelocity = 0.5
	LeftShoulder.MaxVelocity = 0.5
	RightShoulder.DesiredAngle = -3.14
	LeftShoulder.DesiredAngle = 3.14
	RightHip.DesiredAngle = 0
	LeftHip.DesiredAngle = 0
end

function moveSit()
	print(&quot;Move Sit&quot;)
	RightShoulder.MaxVelocity = 0.15
	LeftShoulder.MaxVelocity = 0.15
	RightShoulder.DesiredAngle = 3.14 /2
	LeftShoulder.DesiredAngle = -3.14 /2
	RightHip.DesiredAngle = 3.14 /2
	LeftHip.DesiredAngle = -3.14 /2
end

function getTool()
	
	kidTable = Figure:children()
	if (kidTable ~= nil) then
		numKids = #kidTable
		for i=1,numKids do
			if (kidTable[i].className == &quot;Tool&quot;) then return kidTable[i] end
		end
	end
	
	return nil
end

function getToolAnim(tool)

	c = tool:children()
	for i=1,#c do
		if (c[i].Name == &quot;toolanim&quot; and c[i].className == &quot;StringValue&quot;) then
			return c[i]
		end
	end
	return nil
end

function animateTool()
	
	if (toolAnim == &quot;None&quot;) then
		RightShoulder.DesiredAngle = 1.57
		return
	end

	if (toolAnim == &quot;Slash&quot;) then
		RightShoulder.MaxVelocity = 0.5
		RightShoulder.DesiredAngle = 0
		return
	end

	if (toolAnim == &quot;Lunge&quot;) then
		RightShoulder.MaxVelocity = 0.5
		LeftShoulder.MaxVelocity = 0.5
		RightHip.MaxVelocity = 0.5
		LeftHip.MaxVelocity = 0.5
		RightShoulder.DesiredAngle = 1.57
		LeftShoulder.DesiredAngle = 1.0
		RightHip.DesiredAngle = 1.57
		LeftHip.DesiredAngle = 1.0
		return
	end
end

function move(time)
	local amplitude
	local frequency

	if (pose == &quot;Jumping&quot;) then
		moveJump()
		return
	end

	if (pose == &quot;FreeFall&quot;) then
		moveFreeFall()
		return
	end

	--if (pose == &quot;Climbing&quot;) then
	--	moveClimb(time)
	--	return
	--end

	if (pose == &quot;Seated&quot;) then
		moveSit()
		return
	end


	local climbFudge = 0
	
	if (pose == &quot;Running&quot;) then
		RightShoulder.MaxVelocity = 0.15
		LeftShoulder.MaxVelocity = 0.15
		amplitude = 1
		frequency = 9
	elseif (pose == &quot;Climbing&quot;) then		
		RightShoulder.MaxVelocity = 0.5

		LeftShoulder.MaxVelocity = 0.5

		amplitude = 1
		frequency = 9
		climbFudge = 3.14
	else
		amplitude = 0.1
		frequency = 1
	end

	desiredAngle = amplitude * math.sin(time*frequency)

	RightShoulder.DesiredAngle = desiredAngle + climbFudge
	LeftShoulder.DesiredAngle = desiredAngle - climbFudge
	RightHip.DesiredAngle = -desiredAngle
	LeftHip.DesiredAngle = -desiredAngle


	local tool = getTool()

	if tool ~= nil then
	
		animStringValueObject = getToolAnim(tool)

		if animStringValueObject ~= nil then
			toolAnim = animStringValueObject.Value
			-- message recieved, delete StringValue
			animStringValueObject.Parent = nil
			toolAnimTime = time + .3
		end

		if time &gt; toolAnimTime then
			toolAnimTime = 0
			toolAnim = &quot;None&quot;
		end

		animateTool()

		
	else
		toolAnim = &quot;None&quot;
		toolAnimTime = 0
	end
end


-- connect events

Humanoid.Died:connect(onDied)
Humanoid.Running:connect(onRunning)
Humanoid.Jumping:connect(onJumping)
Humanoid.Climbing:connect(onClimbing)
Humanoid.GettingUp:connect(onGettingUp)
Humanoid.FreeFalling:connect(onFreeFall)
Humanoid.FallingDown:connect(onFallingDown)
Humanoid.Seated:connect(onSeated)

-- main program

local nextTime = 0
local runService = game:service(&quot;RunService&quot;);

while Figure.Parent~=nil do
	time = runService.Stepped:wait()
	if time &gt; nextTime then
		move(time)
		nextTime = time + 0.1
	end
end
</string>
			<bool name="archivable">true</bool>
		</Properties>
	</Item>
</roblox>