module.getQueueFunction=function(h)local b=h:WaitForChild("\072\117\109\097\110\111\105\100")local I=h:WaitForChild("\072\117\109\097\110\111\105\100\082\111\111\116\080\097\114\116")local r=h:WaitForChild("\085\112\112\101\114\084\111\114\115\111")local Q=h:WaitForChild("\076\111\119\101\114\084\111\114\115\111")local l=r:WaitForChild("\087\097\105\115\116")local j=Q:WaitForChild("\082\111\111\116")local o=j.C0 local n=j.C1 local S=l.C1 local x=h:WaitForChild("\082\105\103\104\116\085\112\112\101\114\076\101\103")local L=h:WaitForChild("\082\105\103\104\116\076\111\119\101\114\076\101\103")local u=h:WaitForChild("\076\101\102\116\085\112\112\101\114\076\101\103")local Y=h:WaitForChild("\076\101\102\116\076\111\119\101\114\076\101\103")local V=x:WaitForChild("\082\105\103\104\116\072\105\112")local k=L:WaitForChild("\082\105\103\104\116\075\110\101\101")local N=u:WaitForChild("\076\101\102\116\072\105\112")local X=Y:WaitForChild("\076\101\102\116\075\110\101\101")local w=V.C0 local R=k.C0 local A=N.C0 local B=X.C0 local E=V3(1,0,1)local e=2.3 local K=14 local g,f=0,math.pi local U=CF(0,0,-e/2)local m=RaycastParams.new()m.FilterDescendantsInstances={h}m.IgnoreWater=true m.FilterType=Enum.RaycastFilterType.Blacklist return function(h)local r=math.min(h*10,1)local j=Q.CFrame local o=I.CFrame local n=I.Velocity local x,L local u=b:GetState()==Enum.HumanoidStateType.Climbing if u then x=n L=x.Magnitude E=o.lookVector else x=n*x_and_y L=x.Magnitude if L>.1 then E=E:Lerp(x.unit,r)end end local Y=L/16 local e=(Y*h)*K f=(f+e)%tau g=(g+e)%tau if L>.1 then local h=j:vectorToObjectSpace(x)local b=h*.2 local I=h.X/x.Magnitude do l.C1=l.C1:Lerp(S*(ANGLES(math.rad(b.Z),.1*math.cos(f)-2*math.rad(b.X),math.rad(-b.X))):inverse(),r)end do local h=(o*rhipcf).p local b=(o*rhipcf2).p local I=((CF(b,b+E)*ANGLES(-f,0,0))*U).p local r=I-h local Q=workspace:Raycast(h,r.unit*(r.magnitude+.5),m)local l=Q and Q.Position or h+r.unit*(r.magnitude+.5)local n,S,x=solveLegIK(j*w,l,.55,1.15)V.C0=V.C0:Lerp(j:toObjectSpace(n)*ANGLES(S,0,0),.25)k.C0=k.C0:Lerp(R*ANGLES(x,0,0),.25)end do local h=(o*lhipcf).p local b=(o*lhipcf2).p local I=((CF(b,b+E)*ANGLES(-g,0,0))*U).p local r=I-h local Q=workspace:Raycast(h,r.unit*(r.magnitude+.5),m)local l=Q and Q.Position or h+r.unit*(r.magnitude+.5)local n,S,x=solveLegIK(j*A,l,.55,1.15)N.C0=N.C0:Lerp(j:toObjectSpace(n)*ANGLES(S,0,0),.25)X.C0=X.C0:Lerp(B*ANGLES(x,0,0),.25)end else l.C1=l.C1:Lerp(S,r)do local h=o*rhipcf local b=h.p local I=(h*rIdle).p local r=I-b local Q=workspace:Raycast(b,r.unit*(r.magnitude+.5),m)local l=Q and Q.Position or b+r.unit*(r.magnitude+.5)local n,S,x=solveLegIK(j*w,l,.55,1.15)V.C0=V.C0:Lerp(j:toObjectSpace(n)*ANGLES(S,0,0),.25)k.C0=k.C0:Lerp(R*ANGLES(x,0,0),.25)end do local h=o*lhipcf local b=h.p local I=(h*lIdle).p local r=I-b local Q=workspace:Raycast(b,r.unit*(r.magnitude+.5),m)local l=Q and Q.Position or b+r.unit*(r.magnitude+.5)local n,S,x=solveLegIK(j*A,l,.55,1.15)N.C0=N.C0:Lerp(j:toObjectSpace(n)*ANGLES(S,0,0),.25)X.C0=X.C0:Lerp(B*ANGLES(x,0,0),.25)end end end end return module
--//--//--//--//--//--//--//--//--//--//--//--//--//--//--//--//--//--//--//--//--//--
--//--//--//--//--//--//--//--//--//--//--//--//--//--//--//--//--//--//--//--//--//--
--//--//--//--//--//--//--//--//--//--//--//--//--//--//--//--//--//--//--//--//--//--
--//--//--//--//--//--//--//--//--//--//--//--//--//--//--//--//--//--//--//--//--//--
--//--//--//--//--//--//--//--//--//--//--//--//--//--//--//--//--//--//--//--//--//--

module.getQueueFunction = function(character)
	-- Get all the base parts and values needed to further calculate everything
	local humanoid = character:WaitForChild("Humanoid")
	local rootpart = character:WaitForChild("HumanoidRootPart")
	local uppertorso = character:WaitForChild("UpperTorso")
	local lowertorso = character:WaitForChild("LowerTorso")
	local waistjoint = uppertorso:WaitForChild("Waist")
	local rootjoint = lowertorso:WaitForChild("Root")
	local root0 = rootjoint.C0
	local root1 = rootjoint.C1
	local waist1 = waistjoint.C1

	local rightupperleg = character:WaitForChild("RightUpperLeg")
	local rightlowerleg = character:WaitForChild("RightLowerLeg")
	local leftupperleg = character:WaitForChild("LeftUpperLeg")
	local leftlowerleg = character:WaitForChild("LeftLowerLeg")
	local righthip = rightupperleg:WaitForChild("RightHip")
	local rightknee = rightlowerleg:WaitForChild("RightKnee")
	local lefthip = leftupperleg:WaitForChild("LeftHip")
	local leftknee = leftlowerleg:WaitForChild("LeftKnee")
	local righthip0 = righthip.C0
	local rightknee0 = rightknee.C0
	local lefthip0 = lefthip.C0
	local leftknee0 = leftknee.C0
	--

	local direction = V3(1, 0, 1) -- This will be changed
	local stride = 2.3 -- Changes how far the legs move
	local cycleSpeed = 14 -- How fast the leg-movement cycle is. Change this to suit your needs!
	local left, right = 0, math.pi -- Initial rotations

	local strideCF = CF(0, 0, -stride / 2) -- Turn that stride number into a CFrame we can use

	local raycastParams = RaycastParams.new() -- Used for raycasting
	raycastParams.FilterDescendantsInstances = { character }
	raycastParams.IgnoreWater = true
	raycastParams.FilterType = Enum.RaycastFilterType.Blacklist

	--

	return function(dt) -- dt, or delta, is the amount of time passed between render frames. 1/dt = frames per second
		local dt10 = math.min(dt * 10, 1) -- Normalize dt for our needs

		local lowercf = lowertorso.CFrame -- Our position
		local rootcf = rootpart.CFrame -- Another position
		local rootvel0 = rootpart.Velocity -- Our movement velocity
		local rootvel, rootvelm
		local climbing = humanoid:GetState() == Enum.HumanoidStateType.Climbing -- Are we climbing?

		--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--
		--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--

		if climbing then -- Don't animate if we are climbing, it looks weird
			rootvel = rootvel0
			rootvelm = rootvel.Magnitude
			direction = rootcf.lookVector
		else
			rootvel = rootvel0 * x_and_y
			rootvelm = rootvel.Magnitude

			if rootvelm > 0.1 then
				direction = direction:Lerp(rootvel.unit, dt10)
			end
		end

		--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--
		--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--

		local up = rootvelm / 16
		local cycle = up * dt * cycleSpeed
		right = (right + cycle) % tau
		left = (left + cycle) % tau

		--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--
		--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--

		if rootvelm > 0.1 then --// When moving
			-- Relative Velocity
			local relv0 = lowercf:vectorToObjectSpace(rootvel)
			local relv1 = relv0 * 0.2
			local relvx = relv0.X / rootvel.Magnitude

			do -- Upper Torso
				waistjoint.C1 = waistjoint.C1:Lerp(
					waist1
						* ANGLES(math.rad(relv1.Z), 0.1 * math.cos(right) - 2 * math.rad(relv1.X), math.rad(-relv1.X)):inverse(),
					dt10
				)
			end

			do -- Right Leg
				local hip = (rootcf * rhipcf).p
				local ground = (rootcf * rhipcf2).p
				local desiredPos = (CF(ground, ground + direction) * ANGLES(-right, 0, 0) * strideCF).p
				local offset = (desiredPos - hip)
				local raycastResult = workspace:Raycast(hip, offset.unit * (offset.magnitude + 0.5), raycastParams)
				local footPos = raycastResult and raycastResult.Position
					or (hip + offset.unit * (offset.magnitude + 0.5))

				local plane, th1, th2 = solveLegIK(lowercf * righthip0, footPos, 0.55, 1.15) -- 0.55,1.15
				righthip.C0 = righthip.C0:Lerp(lowercf:toObjectSpace(plane) * ANGLES(th1, 0, 0), 0.25)
				rightknee.C0 = rightknee.C0:Lerp(rightknee0 * ANGLES(th2, 0, 0), 0.25)
			end

			do -- Left Leg
				local hip = (rootcf * lhipcf).p
				local ground = (rootcf * lhipcf2).p
				local desiredPos = (CF(ground, ground + direction) * ANGLES(-left, 0, 0) * strideCF).p
				local offset = (desiredPos - hip)
				local raycastResult = workspace:Raycast(hip, offset.unit * (offset.magnitude + 0.5), raycastParams)
				local footPos = raycastResult and raycastResult.Position
					or (hip + offset.unit * (offset.magnitude + 0.5))

				local plane, th1, th2 = solveLegIK(lowercf * lefthip0, footPos, 0.55, 1.15)
				lefthip.C0 = lefthip.C0:Lerp(lowercf:toObjectSpace(plane) * ANGLES(th1, 0, 0), 0.25)
				leftknee.C0 = leftknee.C0:Lerp(leftknee0 * ANGLES(th2, 0, 0), 0.25)
			end

			--|||||||||||--
			--|||||||||||--
		else --// When not moving
			-- Upper Torso
			waistjoint.C1 = waistjoint.C1:Lerp(waist1, dt10)

			do -- Right Leg
				local hipcf = (rootcf * rhipcf)
				local hip = hipcf.p
				local desiredPos = (hipcf * rIdle).p
				local offset = (desiredPos - hip)
				local raycastResult = workspace:Raycast(hip, offset.unit * (offset.magnitude + 0.5), raycastParams)
				local footPos = raycastResult and raycastResult.Position
					or (hip + offset.unit * (offset.magnitude + 0.5))

				local plane, th1, th2 = solveLegIK(lowercf * righthip0, footPos, 0.55, 1.15)
				righthip.C0 = righthip.C0:Lerp(lowercf:toObjectSpace(plane) * ANGLES(th1, 0, 0), 0.25)
				rightknee.C0 = rightknee.C0:Lerp(rightknee0 * ANGLES(th2, 0, 0), 0.25)
			end

			do -- Left Leg
				local hipcf = (rootcf * lhipcf)
				local hip = hipcf.p
				local desiredPos = (hipcf * lIdle).p
				local offset = (desiredPos - hip)
				local raycastResult = workspace:Raycast(hip, offset.unit * (offset.magnitude + 0.5), raycastParams)
				local footPos = raycastResult and raycastResult.Position
					or (hip + offset.unit * (offset.magnitude + 0.5))

				local plane, th1, th2 = solveLegIK(lowercf * lefthip0, footPos, 0.55, 1.15)
				lefthip.C0 = lefthip.C0:Lerp(lowercf:toObjectSpace(plane) * ANGLES(th1, 0, 0), 0.25)
				leftknee.C0 = leftknee.C0:Lerp(leftknee0 * ANGLES(th2, 0, 0), 0.25)
			end

			--|||||||||||--
			--|||||||||||--
		end
	end

	--
end

return module
