local i=game:GetService("\082\101\112\108\105\099\097\116\101\100\083\116\111\114\097\103\101")local M=game:GetService("\080\108\097\121\101\114\115")local D=i:WaitForChild("\099\111\109\109\111\110")local p=i:WaitForChild("\108\105\098")local x=D:WaitForChild("\111\098\106\101\099\116")local K=require(x:WaitForChild("\076\101\103\065\110\105\109\097\116\111\114\079\098\106\101\099\116"))local o=require(p:WaitForChild("\080\105\122\122\097\065\108\112\097\099\097"))local j=o.GameModule:extend("\069\103\076\101\103\065\110\105\109\097\116\111\114")local w={}local function R(i)print("\065\116\116\097\099\104\101\100 \116\111\058",i)local M=i:WaitForChild("\072\117\109\097\110\111\105\100")local D=K.new(i)w[i]=D M.Died:Connect(function()print("\082\101\109\111\118\105\110\103 \097\110\105\109\097\116\111\114 \102\111\114\058 ",i)w[i]=nil end)i.AncestryChanged:Connect(function(M,D)if D==nil then print("\082\101\109\111\118\105\110\103 \097\110\105\109\097\116\111\114 \102\111\114\058 ",i)w[i]=nil end end)return D end local function U(i)i.CharacterAdded:Connect(function(i)R(i)end)end local function e()for i,M in pairs(M:GetPlayers())do local D=M.Character if D then spawn(function()R(D)end)end U(M)end end function j.renderStep(D,i,M)for D,p in pairs(w)do if D and D:FindFirstChild("\084\111\114\115\111")then p:step(i,M)end end end function j.init(i)e()M.PlayerAdded:Connect(function(i)U(i)end)local D=tick()local p=tick()-D local x=tick()local K=x;(game:GetService("\082\117\110\083\101\114\118\105\099\101")):BindToRenderStep("\101\103\108\101\103",Enum.RenderPriority.Last.Value,function()x=tick()local M=x-K K=x i:renderStep(p,M)end)end return j
-- Attaches animators to you and ur frens

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")

local common = ReplicatedStorage:WaitForChild("common")
local lib = ReplicatedStorage:WaitForChild("lib")
local object = common:WaitForChild("object")

local LegAnimator = require(object:WaitForChild("LegAnimatorObject"))
local PizzaAlpaca = require(lib:WaitForChild("PizzaAlpaca"))

local EgLegAnimator = PizzaAlpaca.GameModule:extend("EgLegAnimator")

local animators = {}

local function attachNewAnimator(rig)
	print("Attached to:", rig)

	local humanoid = rig:WaitForChild("Humanoid")
	local animator = LegAnimator.new(rig)

	animators[rig] = animator

	humanoid.Died:Connect(function()
		print("Removing animator for: ", rig)
		animators[rig] = nil
	end)

	rig.AncestryChanged:Connect(function(newChild,newParent)
		if newParent == nil then
			print("Removing animator for: ", rig)
			animators[rig] = nil
		end
	end)

	return animator
end

local function bindAttacher(player)
	player.CharacterAdded:Connect(function(char)
		attachNewAnimator(char)
	end)
end

local function attachAnimatorsToAllPlayers()
	for _,player in pairs(Players:GetPlayers()) do
		local rig = player.Character
		if rig then
			spawn(function()
				attachNewAnimator(rig)
			end)
		end
		bindAttacher(player)
	end
end

function EgLegAnimator:renderStep(elapsed,dt)

	for rig,animator in pairs(animators) do
		if rig and rig:FindFirstChild("Torso") then
			animator:step(elapsed,dt)
		end
	end

end

function EgLegAnimator:init()
	attachAnimatorsToAllPlayers()

	Players.PlayerAdded:Connect(function(player)
		bindAttacher(player)
	end)
	local start = tick()
	local elapsed = tick()-start
	local now = tick()
	local last = now
	game:GetService("RunService"):BindToRenderStep("egleg",Enum.RenderPriority.Last.Value,function()
		now = tick()
		local dt = now - last
		last = now
		self:renderStep(elapsed,dt)
	end)
end

return EgLegAnimator