function waitForChild(g,T)while true do local X=g:findFirstChild(T)if X then return X end g.ChildAdded:wait()end end local g=script.Parent local T=waitForChild(g,"\084\111\114\115\111")local X=waitForChild(T,"\082\105\103\104\116 \083\104\111\117\108\100\101\114")local E=waitForChild(T,"\076\101\102\116 \083\104\111\117\108\100\101\114")local a=waitForChild(T,"\082\105\103\104\116 \072\105\112")local s=waitForChild(T,"\076\101\102\116 \072\105\112")local O=waitForChild(T,"\078\101\099\107")local B=waitForChild(g,"\072\117\109\097\110\111\105\100")local z="\083\116\097\110\100\105\110\103"local H="\078\111\110\101"local Z=0 local d=false function onRunning(g)if d then return end if g>0 then z="\082\117\110\110\105\110\103"else z="\083\116\097\110\100\105\110\103"end end function onDied()z="\068\101\097\100"local T=g:GetChildren()for g=1,#T,1 do if T.className=="\080\097\114\116"then Debris.AddItem(T[g],60)end end end function onJumping()d=false z="\074\117\109\112\105\110\103"end function onClimbing()z="\067\108\105\109\098\105\110\103"end function onGettingUp()z="\071\101\116\116\105\110\103\085\112"end function onFreeFall()z="\070\114\101\101\070\097\108\108"end function onDancing()z="\068\097\110\099\105\110\103"end function onFallingDown()z="\070\097\108\108\105\110\103\068\111\119\110"end function onSeated()d=true z="\083\101\097\116\101\100"end function moveJump()X.MaxVelocity=.5 E.MaxVelocity=.5 X.DesiredAngle=-3.14 E.DesiredAngle=-3.14 a.DesiredAngle=0 s.DesiredAngle=0 end function moveFreeFall()X.MaxVelocity=.5 E.MaxVelocity=.5 X.DesiredAngle=-1 E.DesiredAngle=-1 a.DesiredAngle=0 s.DesiredAngle=0 end function moveFloat()X.MaxVelocity=.5 E.MaxVelocity=.5 X.DesiredAngle=-1.57 E.DesiredAngle=1.57 a.DesiredAngle=1.57 s.DesiredAngle=-1.57 end function moveBoogy()while z=="\066\111\111\103\121"do wait(.5)X.MaxVelocity=1 E.MaxVelocity=1 X.DesiredAngle=-3.14 E.DesiredAngle=0 a.DesiredAngle=1.57 s.DesiredAngle=0 wait(.5)X.MaxVelocity=1 E.MaxVelocity=1 X.DesiredAngle=0 E.DesiredAngle=-3.14 a.DesiredAngle=0 s.DesiredAngle=1.57 end end function moveZombie()X.MaxVelocity=.5 E.MaxVelocity=.5 X.DesiredAngle=-1.57 E.DesiredAngle=1.57 a.DesiredAngle=0 s.DesiredAngle=0 end function movePunch()script.Parent.Torso.Anchored=true X.MaxVelocity=60 E.MaxVelocity=.5 X.DesiredAngle=-1.57 E.DesiredAngle=0 a.DesiredAngle=0 s.DesiredAngle=0 wait(1)script.Parent.Torso.Anchored=false z="\083\116\097\110\100\105\110\103"end function moveKick()X.MaxVelocity=.5 E.MaxVelocity=.5 X.DesiredAngle=0 E.DesiredAngle=0 a.MaxVelocity=40 a.DesiredAngle=1.57 s.DesiredAngle=0 wait(1)z="\083\116\097\110\100\105\110\103"end function moveFly()X.MaxVelocity=.5 E.MaxVelocity=.5 X.DesiredAngle=0 E.DesiredAngle=0 a.MaxVelocity=40 a.DesiredAngle=1.57 s.DesiredAngle=0 wait(1)z="\083\116\097\110\100\105\110\103"end function moveClimb()X.MaxVelocity=.5 E.MaxVelocity=.5 X.DesiredAngle=-3.14 E.DesiredAngle=3.14 a.DesiredAngle=0 s.DesiredAngle=0 end function moveSit()X.MaxVelocity=.15 E.MaxVelocity=.15 X.DesiredAngle=-1.57 E.DesiredAngle=-1.57 a.DesiredAngle=1.57 s.DesiredAngle=-1.57 end function getTool()kidTable=g:children()if kidTable~=nil then numKids=#kidTable for g=1,numKids,1 do if kidTable[g].className=="\084\111\111\108"then return kidTable[g]end end end return nil end function getToolAnim(g)c=g:children()for g=1,#c,1 do if c[g].Name=="\116\111\111\108\097\110\105\109"and c[g].className=="\083\116\114\105\110\103\086\097\108\117\101"then return c[g]end end return nil end function animateTool()if H=="\078\111\110\101"then X.DesiredAngle=-1.57 return end if H=="\083\108\097\115\104"then X.MaxVelocity=.5 X.DesiredAngle=0 return end if H=="\076\117\110\103\101"then X.MaxVelocity=.5 E.MaxVelocity=.5 a.MaxVelocity=.5 s.MaxVelocity=.5 X.DesiredAngle=-1.57 E.DesiredAngle=1.0 a.DesiredAngle=1.57 s.DesiredAngle=1.0 return end end function move(g)local T local c if z=="\074\117\109\112\105\110\103"then moveJump()return end if z=="\090\111\109\098\105\101"then moveZombie()return end if z=="\066\111\111\103\121"then moveBoogy()return end if z=="\070\108\111\097\116"then moveFloat()return end if z=="\080\117\110\099\104"then movePunch()return end if z=="\075\105\099\107"then moveKick()return end if z=="\070\108\121"then moveFly()return end if z=="\070\114\101\101\070\097\108\108"then moveFreeFall()return end if z=="\067\108\105\109\098\105\110\103"then moveClimb()return end if z=="\083\101\097\116\101\100"then moveSit()return end T=.1 c=1 X.MaxVelocity=.15 E.MaxVelocity=.15 if z=="\082\117\110\110\105\110\103"then T=1 c=9 elseif z=="\068\097\110\099\105\110\103"then T=2 c=16 end desiredAngle=T*math.sin(g*c)if z~="\068\097\110\099\105\110\103"then X.DesiredAngle=-desiredAngle E.DesiredAngle=desiredAngle a.DesiredAngle=-desiredAngle s.DesiredAngle=-desiredAngle else X.DesiredAngle=-desiredAngle E.DesiredAngle=desiredAngle a.DesiredAngle=-desiredAngle s.DesiredAngle=-desiredAngle end local O=getTool()if O~=nil then animStringValueObject=getToolAnim(O)if animStringValueObject~=nil then H=animStringValueObject.Value animStringValueObject.Parent=nil Z=g+.3 end if g>Z then Z=0 H="\078\111\110\101"end animateTool()else H="\078\111\110\101"Z=0 end end
------------------
------------------

function waitForChild(parent, childName)
	while true do
		local child = parent:findFirstChild(childName)
		if child then
			return child
		end
		parent.ChildAdded:wait()
	end
end

local Figure = script.Parent
local Torso = waitForChild(Figure, "Torso")
local RightShoulder = waitForChild(Torso, "Right Shoulder")
local LeftShoulder = waitForChild(Torso, "Left Shoulder")
local RightHip = waitForChild(Torso, "Right Hip")
local LeftHip = waitForChild(Torso, "Left Hip")
local Neck = waitForChild(Torso, "Neck")
local Humanoid = waitForChild(Figure, "Humanoid")
local pose = "Standing"

local toolAnim = "None"
local toolAnimTime = 0

local isSeated = false

function onRunning(speed)
	if isSeated then
		return
	end

	if speed > 0 then
		pose = "Running"
	else
		pose = "Standing"
	end
end

function onDied()
	pose = "Dead"

	local parts = Figure:GetChildren()
	for i = 1, #parts do
		if parts.className == "Part" then
			Debris.AddItem(parts[i], 60)
		end
	end
end

function onJumping()
	isSeated = false
	pose = "Jumping"
end

function onClimbing()
	pose = "Climbing"
end

function onGettingUp()
	pose = "GettingUp"
end

function onFreeFall()
	pose = "FreeFall"
end

function onDancing()
	pose = "Dancing"
end

function onFallingDown()
	pose = "FallingDown"
end

function onSeated()
	isSeated = true
	pose = "Seated"
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 moveFloat()
	RightShoulder.MaxVelocity = 0.5
	LeftShoulder.MaxVelocity = 0.5
	RightShoulder.DesiredAngle = -1.57
	LeftShoulder.DesiredAngle = 1.57
	RightHip.DesiredAngle = 1.57
	LeftHip.DesiredAngle = -1.57
end

function moveBoogy()
	while pose == "Boogy" do
		wait(0.5)
		RightShoulder.MaxVelocity = 1
		LeftShoulder.MaxVelocity = 1
		RightShoulder.DesiredAngle = -3.14
		LeftShoulder.DesiredAngle = 0
		RightHip.DesiredAngle = 1.57
		LeftHip.DesiredAngle = 0
		wait(0.5)
		RightShoulder.MaxVelocity = 1
		LeftShoulder.MaxVelocity = 1
		RightShoulder.DesiredAngle = 0
		LeftShoulder.DesiredAngle = -3.14
		RightHip.DesiredAngle = 0
		LeftHip.DesiredAngle = 1.57
	end
end

function moveZombie()
	RightShoulder.MaxVelocity = 0.5
	LeftShoulder.MaxVelocity = 0.5
	RightShoulder.DesiredAngle = -1.57
	LeftShoulder.DesiredAngle = 1.57
	RightHip.DesiredAngle = 0
	LeftHip.DesiredAngle = 0
end

function movePunch()
	script.Parent.Torso.Anchored = true
	RightShoulder.MaxVelocity = 60
	LeftShoulder.MaxVelocity = 0.5
	RightShoulder.DesiredAngle = -1.57
	LeftShoulder.DesiredAngle = 0
	RightHip.DesiredAngle = 0
	LeftHip.DesiredAngle = 0
	wait(1)
	script.Parent.Torso.Anchored = false
	pose = "Standing"
end

function moveKick()
	RightShoulder.MaxVelocity = 0.5
	LeftShoulder.MaxVelocity = 0.5
	RightShoulder.DesiredAngle = 0
	LeftShoulder.DesiredAngle = 0
	RightHip.MaxVelocity = 40
	RightHip.DesiredAngle = 1.57
	LeftHip.DesiredAngle = 0
	wait(1)
	pose = "Standing"
end

function moveFly()
	RightShoulder.MaxVelocity = 0.5
	LeftShoulder.MaxVelocity = 0.5
	RightShoulder.DesiredAngle = 0
	LeftShoulder.DesiredAngle = 0
	RightHip.MaxVelocity = 40
	RightHip.DesiredAngle = 1.57
	LeftHip.DesiredAngle = 0
	wait(1)
	pose = "Standing"
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()
	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 == "Tool" 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 == "toolanim" and c[i].className == "StringValue" then
			return c[i]
		end
	end
	return nil
end

function animateTool()
	if toolAnim == "None" then
		RightShoulder.DesiredAngle = -1.57
		return
	end

	if toolAnim == "Slash" then
		RightShoulder.MaxVelocity = 0.5
		RightShoulder.DesiredAngle = 0
		return
	end

	if toolAnim == "Lunge" 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 == "Jumping" then
		moveJump()
		return
	end

	if pose == "Zombie" then
		moveZombie()
		return
	end

	if pose == "Boogy" then
		moveBoogy()
		return
	end

	if pose == "Float" then
		moveFloat()
		return
	end

	if pose == "Punch" then
		movePunch()
		return
	end

	if pose == "Kick" then
		moveKick()
		return
	end

	if pose == "Fly" then
		moveFly()
		return
	end

	if pose == "FreeFall" then
		moveFreeFall()
		return
	end

	if pose == "Climbing" then
		moveClimb()
		return
	end

	if pose == "Seated" then
		moveSit()
		return
	end

	amplitude = 0.1
	frequency = 1

	RightShoulder.MaxVelocity = 0.15
	LeftShoulder.MaxVelocity = 0.15
	if pose == "Running" then
		amplitude = 1
		frequency = 9
	elseif pose == "Dancing" then
		amplitude = 2
		frequency = 16
	end

	desiredAngle = amplitude * math.sin(time * frequency)
	if pose ~= "Dancing" then
		RightShoulder.DesiredAngle = -desiredAngle
		LeftShoulder.DesiredAngle = desiredAngle
		RightHip.DesiredAngle = -desiredAngle
		LeftHip.DesiredAngle = -desiredAngle
	else
		RightShoulder.DesiredAngle = -desiredAngle
		LeftShoulder.DesiredAngle = desiredAngle
		RightHip.DesiredAngle = -desiredAngle
		LeftHip.DesiredAngle = -desiredAngle
	end

	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 + 0.3
		end

		if time > toolAnimTime then
			toolAnimTime = 0
			toolAnim = "None"
		end

		animateTool()
	else
		toolAnim = "None"
		toolAnimTime = 0
	end
end
