function onRunning(p)if p>0 then pose="\082\117\110\110\105\110\103"else pose="\083\116\097\110\100\105\110\103"end end function onDied()pose="\068\101\097\100"end function onJumping()pose="\074\117\109\112\105\110\103"end function onClimbing()pose="\067\108\105\109\098\105\110\103"end function onGettingUp()pose="\071\101\116\116\105\110\103\085\112"end function onFreeFall()pose="\070\114\101\101\070\097\108\108"end function onFallingDown()pose="\070\097\108\108\105\110\103\068\111\119\110"end function onSeated()pose="\083\101\097\116\101\100"end function onPlatformStanding()pose="\080\108\097\116\102\111\114\109\083\116\097\110\100\105\110\103"end function moveJump()RightShoulder.MaxVelocity=.5 LeftShoulder.MaxVelocity=.5 RightShoulder.DesiredAngle=3.14 LeftShoulder.DesiredAngle=-3.14 RightHip.DesiredAngle=0 LeftHip.DesiredAngle=0 end function moveFreeFall()RightShoulder.MaxVelocity=.5 LeftShoulder.MaxVelocity=.5 RightShoulder.DesiredAngle=3.14 LeftShoulder.DesiredAngle=-3.14 RightHip.DesiredAngle=0 LeftHip.DesiredAngle=0 end function moveSit()RightShoulder.MaxVelocity=.15 LeftShoulder.MaxVelocity=.15 RightShoulder.DesiredAngle=1.57 LeftShoulder.DesiredAngle=-1.57 RightHip.DesiredAngle=1.57 LeftHip.DesiredAngle=-1.57 end function animate(p)local A local l if pose=="\074\117\109\112\105\110\103"then moveJump()return end if pose=="\070\114\101\101\070\097\108\108"then moveFreeFall()return end if pose=="\083\101\097\116\101\100"then moveSit()return end local G=0 if pose=="\082\117\110\110\105\110\103"then RightShoulder.MaxVelocity=.15 LeftShoulder.MaxVelocity=.15 A=1 l=9 elseif pose=="\067\108\105\109\098\105\110\103"then RightShoulder.MaxVelocity=.5 LeftShoulder.MaxVelocity=.5 A=1 l=9 G=3.14 else A=.1 l=1 end desiredAngle=A*math.sin(p*l)if not chasing and l==9 then l=4 end if chasing then else RightShoulder.DesiredAngle=desiredAngle+G LeftShoulder.DesiredAngle=desiredAngle-G RightHip.DesiredAngle=-desiredAngle LeftHip.DesiredAngle=-desiredAngle end end function attack(p,A)if p-lastattack>=.25 then local l,G=raycast(Torso.Position,(A-Torso.Position).unit,attackrange)if l and l.Parent~=nil then local p=l.Parent:FindFirstChild("\072\117\109\097\110\111\105\100")local A=l.Parent:FindFirstChild("\084\069\065\077")if p and(A and A.Value~=sp.TEAM.Value)then local A=sp:FindFirstChild("\099\114\101\097\116\111\114")if A then if A.Value~=nil then if A.Value~=game.Players:GetPlayerFromCharacter(p.Parent)then for p,A in ipairs(p:GetChildren())do if A.Name=="\099\114\101\097\116\111\114"then A:remove()end end;(A:clone()).Parent=p else return end end end if Anim then Anim:Play(nil,nil,1.5)end p:TakeDamage(damage)hitsound.Volume=1 hitsound.Pitch=.75+math.random()*.5 hitsound:Play()end end lastattack=p end end 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)Humanoid.PlatformStanding:connect(onPlatformStanding)function populatehumanoids(p)if p.ClassName=="\072\117\109\097\110\111\105\100"then if p.Parent:FindFirstChild("\084\069\065\077")and(p.Parent:FindFirstChild("\084\069\065\077")).Value~=sp.TEAM.Value then table.insert(humanoids,p)end end for p,A in ipairs(p:GetChildren())do populatehumanoids(A)end end
--[[BodyColors.HeadColor=BrickColor.new("Grime")
local randomcolor1=colors[math.random(1,#colors)]
BodyColors.TorsoColor=BrickColor.new(randomcolor1)
BodyColors.LeftArmColor=BrickColor.new(randomcolor1)
BodyColors.RightArmColor=BrickColor.new(randomcolor1)
local randomcolor2=colors[math.random(1,#colors)]
BodyColors.LeftLegColor=BrickColor.new(randomcolor2)
BodyColors.RightLegColor=BrickColor.new(randomcolor2)]]

function onRunning(speed)
	if speed > 0 then
		pose = "Running"
	else
		pose = "Standing"
	end
end
function onDied()
	pose = "Dead"
end
function onJumping()
	pose = "Jumping"
end
function onClimbing()
	pose = "Climbing"
end
function onGettingUp()
	pose = "GettingUp"
end
function onFreeFall()
	pose = "FreeFall"
end
function onFallingDown()
	pose = "FallingDown"
end
function onSeated()
	pose = "Seated"
end
function onPlatformStanding()
	pose = "PlatformStanding"
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 = 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 animate(time)
	local amplitude
	local frequency
	if pose == "Jumping" then
		moveJump()
		return
	end
	if pose == "FreeFall" then
		moveFreeFall()
		return
	end
	if pose == "Seated" then
		moveSit()
		return
	end
	local climbFudge = 0
	if pose == "Running" then
		RightShoulder.MaxVelocity = 0.15
		LeftShoulder.MaxVelocity = 0.15
		amplitude = 1
		frequency = 9
	elseif pose == "Climbing" 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)
	if not chasing and frequency == 9 then
		frequency = 4
	end
	if chasing then
		--[[RightShoulder.DesiredAngle=math.pi/2
		LeftShoulder.DesiredAngle=-math.pi/2
		RightHip.DesiredAngle=-desiredAngle*2
		LeftHip.DesiredAngle=-desiredAngle*2]]
	else
		RightShoulder.DesiredAngle = desiredAngle + climbFudge
		LeftShoulder.DesiredAngle = desiredAngle - climbFudge
		RightHip.DesiredAngle = -desiredAngle
		LeftHip.DesiredAngle = -desiredAngle
	end
end

function attack(time, attackpos)
	if time - lastattack >= 0.25 then
		local hit, pos = raycast(Torso.Position, (attackpos - Torso.Position).unit, attackrange)
		if hit and hit.Parent ~= nil then
			local h = hit.Parent:FindFirstChild("Humanoid")
			local TEAM = hit.Parent:FindFirstChild("TEAM")
			if h and TEAM and TEAM.Value ~= sp.TEAM.Value then
				local creator = sp:FindFirstChild("creator")
				if creator then
					if creator.Value ~= nil then
						if creator.Value ~= game.Players:GetPlayerFromCharacter(h.Parent) then
							for i, oldtag in ipairs(h:GetChildren()) do
								if oldtag.Name == "creator" then
									oldtag:remove()
								end
							end
							creator:clone().Parent = h
						else
							return
						end
					end
				end
				if Anim then
					Anim:Play(nil, nil, 1.5)
				end
				h:TakeDamage(damage)
				hitsound.Volume = 1
				hitsound.Pitch = 0.75 + (math.random() * 0.5)
				hitsound:Play()
				--[[if RightShoulder and LeftShoulder then
					RightShoulder.CurrentAngle=0
					LeftShoulder.CurrentAngle=0
				end]]
			end
		end
		lastattack = time
	end
end

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)
Humanoid.PlatformStanding:connect(onPlatformStanding)

function populatehumanoids(mdl)
	if mdl.ClassName == "Humanoid" then
		if mdl.Parent:FindFirstChild("TEAM") and mdl.Parent:FindFirstChild("TEAM").Value ~= sp.TEAM.Value then
			table.insert(humanoids, mdl)
		end
	end
	for i2, mdl2 in ipairs(mdl:GetChildren()) do
		populatehumanoids(mdl2)
	end
end
