local v=game:GetService("\082\101\112\108\105\099\097\116\101\100\083\116\111\114\097\103\101")local d=game:GetService("\082\117\110\083\101\114\118\105\099\101")local q=v.Source.IKObjectsFolder.LimbChain local R=require(q)local m=workspace.R15Dummy local B=m.LowerTorso.Root local s=m.LeftUpperLeg.LeftHip local g=m.LeftLowerLeg.LeftKnee local i=m.LeftFoot.LeftAnkle local W={s,g,i}local L=R.new(W)local w=m.RightUpperLeg.RightHip local k=m.RightLowerLeg.RightKnee local c=m.RightFoot.RightAnkle local r={w;k,c}local C=R.new(r)local X=m.UpperTorso.Waist local o=m.Head.Neck local M={B;o}local F=R.new(M,false,X)d.Heartbeat:Connect(function()local v=workspace.LTarget.Position local d=workspace.RTarget.Position local q=workspace.R15UpTarget.Position L:IterateOnce(v,.1)L:UpdateMotors()F:IterateOnce(q,.1)F:UpdateMotors()C:IterateOnce(d,.1)C:UpdateMotors()end)
--This script controls the r15 avatar

--Get service
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RunService = game:GetService("RunService")

--Modules required
local IKControllerPointer = ReplicatedStorage.Source.IKObjectsFolder.LimbChain
local LimbChain = require(IKControllerPointer)

--Point to dummy in the workspace
local dummy = workspace.R15Dummy

------------Left Leg--------------------------

--Get the motors of the left leg chain
local rootMotor = dummy.LowerTorso.Root
local lUpperLegMotor = dummy.LeftUpperLeg.LeftHip
local lLowerLegMotor = dummy.LeftLowerLeg.LeftKnee
local lfoot = dummy.LeftFoot.LeftAnkle

--Create the left leg chain
local leftLegMotorTable = {lUpperLegMotor,lLowerLegMotor,lfoot}
local leftLegChain = LimbChain.new(leftLegMotorTable)

------------Right Leg--------------------------

--Get the motors of the right leg chain
local rUpperLegMotor = dummy.RightUpperLeg.RightHip
local rLowerLegMotor = dummy.RightLowerLeg.RightKnee
local rfoot = dummy.RightFoot.RightAnkle

--Create the right leg chain
local rightLegMotorTable = {rUpperLegMotor,rLowerLegMotor,rfoot}
local rightLegChain = LimbChain.new(rightLegMotorTable)

----------Spine Chain--------------------
--idk waist
local waistMotor = dummy.UpperTorso.Waist
local neck = dummy.Head.Neck

--create the spine chain
local spineMotorTable = {rootMotor,neck}
local spineChain = LimbChain.new(spineMotorTable,false,waistMotor)



RunService.Heartbeat:Connect(function()
    --targets for left and right leg and spine
    local target = workspace.LTarget.Position
    local rightTarget = workspace.RTarget.Position
    local upTarget = workspace.R15UpTarget.Position

    leftLegChain:IterateOnce(target,0.1)
    leftLegChain:UpdateMotors()

    spineChain:IterateOnce(upTarget,0.1)
    spineChain:UpdateMotors()

    rightLegChain:IterateOnce(rightTarget,0.1)
    rightLegChain:UpdateMotors()

end)
