Advertisement
Dark_Agent

Limb reanim orbit 1

Jun 26th, 2025 (edited)
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 7.55 KB | Gaming | 0 0
  1. local g = getgenv and getgenv() or _G
  2.  
  3. do
  4.     -- Settings:
  5.    
  6.     local DefaultAnimations = true
  7.     local DisableCharacterCollisions = true
  8.     local InstantRespawn = true
  9.     local ParentCharacterToRig = true
  10.     local RigTransparency = 1
  11.    
  12.     -- Circle Movement Settings
  13.     local CircleRadius = g.CircleRadius
  14.     local CircleSpeed = g.CircleSpeed
  15.     local LimbFloatHeight = g.LimbFloatHeight
  16.    
  17.     --
  18.    
  19.     local CFrameidentity = CFrame.identity
  20.     local Inverse = CFrameidentity.Inverse
  21.     local ToAxisAngle = CFrameidentity.ToAxisAngle
  22.     local ToEulerAnglesXYZ = CFrameidentity.ToEulerAnglesXYZ
  23.     local ToObjectSpace = CFrameidentity.ToObjectSpace
  24.    
  25.     local Connections = {}
  26.    
  27.     local Disconnect = nil
  28.    
  29.     local game = game
  30.     local FindFirstChild = game.FindFirstChild
  31.     local FindFirstChildOfClass = game.FindFirstChildOfClass
  32.     local Players = FindFirstChildOfClass(game, "Players")
  33.     local LocalPlayer = Players.LocalPlayer
  34.     local Character = LocalPlayer.Character
  35.     local CharacterAdded = LocalPlayer.CharacterAdded
  36.     local Connect = CharacterAdded.Connect
  37.     local Wait = CharacterAdded.Wait
  38.     local Rig = Players:CreateHumanoidModelFromDescription(Players:GetHumanoidDescriptionFromUserId(LocalPlayer.UserId), Enum.HumanoidRigType.R6)
  39.     local RigAnimate = Rig.Animate
  40.     local RigHumanoid = Rig.Humanoid
  41.     local RigRootPart = RigHumanoid.RootPart
  42.     local RunService = FindFirstChildOfClass(game, "RunService")
  43.     local Workspace = FindFirstChildOfClass(game, "Workspace")
  44.     local GetDescendants = game.GetDescendants
  45.     local IsA = game.IsA
  46.     local WaitForChild = game.WaitForChild
  47.    
  48.     local BreakJoints = Instance.new("Model").BreakJoints
  49.    
  50.     local mathsin = math.sin
  51.     local mathcos = math.cos
  52.     local mathrad = math.rad
  53.  
  54.     local next = next
  55.    
  56.     local osclock = os.clock
  57.    
  58.     local replicatesignal = replicatesignal
  59.    
  60.     local RootPartCFrame = nil
  61.    
  62.     local Motor6Ds = {}
  63.     local LimbMotors = {}
  64.    
  65.     local select = select
  66.    
  67.     local sethiddenproperty = sethiddenproperty
  68.    
  69.     local tableinsert = table.insert
  70.    
  71.     local Vector3 = Vector3
  72.     local Vector3new = Vector3.new
  73.     local Vector3zero = Vector3.zero
  74.    
  75.     local CFramenew = CFrame.new
  76.     local CFrameAngles = CFrame.Angles
  77.    
  78.     RigAnimate.Enabled = false 
  79.    
  80.     Rig.Name = LocalPlayer.Name
  81.     RigHumanoid.DisplayName = LocalPlayer.DisplayName
  82.    
  83.     if Character then
  84.         if replicatesignal then
  85.             if InstantRespawn then
  86.                 replicatesignal(LocalPlayer.ConnectDiedSignalBackend)
  87.                 task.wait(Players.RespawnTime - 0.1)
  88.                
  89.                 local RootPart = FindFirstChild(Character, "HumanoidRootPart")
  90.  
  91.                 if RootPart then
  92.                     RootPartCFrame = RootPart.CFrame
  93.                 end
  94.                
  95.                 replicatesignal(LocalPlayer.Kill)
  96.             end
  97.         else
  98.             BreakJoints(Character)
  99.         end
  100.     end
  101.    
  102.     Character = Wait(CharacterAdded)
  103.    
  104.     local Animate = WaitForChild(Character, "Animate")
  105.     Animate.Enabled = false
  106.  
  107.     local RootPart = WaitForChild(Character, "HumanoidRootPart")
  108.     RigRootPart.CFrame = RootPartCFrame or RootPart.CFrame
  109.    
  110.     -- Store references to character limbs
  111.     local CharLeftArm = FindFirstChild(Character, "Left Arm")
  112.     local CharRightArm = FindFirstChild(Character, "Right Arm")
  113.     local CharLeftLeg = FindFirstChild(Character, "Left Leg")
  114.     local CharRightLeg = FindFirstChild(Character, "Right Leg")
  115.    
  116.     Disconnect = Connect(RigHumanoid.Died, function()
  117.         for Index, Connection in Connections do
  118.             Disconnect(Connection)
  119.         end
  120.        
  121.         if ParentCharacterToRig then
  122.             Character.Parent = Rig.Parent
  123.         end
  124.        
  125.         BreakJoints(Character)
  126.         Rig:Destroy()
  127.     end).Disconnect
  128.    
  129.     -- Identify limb motors
  130.     for Index, Descendant in next, GetDescendants(Character) do
  131.         if IsA(Descendant, "Motor6D") then
  132.             local rigPart0 = FindFirstChild(Rig, Descendant.Part0.Name)
  133.             local rigPart1 = FindFirstChild(Rig, Descendant.Part1.Name)
  134.            
  135.             if rigPart0 and rigPart1 then
  136.                 Motor6Ds[Descendant] = {
  137.                     Part0 = rigPart0,
  138.                     Part1 = rigPart1
  139.                 }
  140.                
  141.                 -- Check if this motor controls a limb
  142.                 local part1Name = Descendant.Part1.Name
  143.                 if part1Name == "Left Arm" or part1Name == "Right Arm" or part1Name == "Left Leg" or part1Name == "Right Leg" then
  144.                     LimbMotors[Descendant] = true
  145.                 end
  146.             end
  147.         end
  148.     end
  149.    
  150.     for Index, Descendant in next, GetDescendants(Rig) do
  151.         if IsA(Descendant, "BasePart") then
  152.             Descendant.Transparency = RigTransparency
  153.         end
  154.     end
  155.    
  156.     Rig.Parent = Workspace
  157.    
  158.     if ParentCharacterToRig then
  159.         Character.Parent = Rig
  160.     end
  161.    
  162.     task.defer(function()
  163.         local CurrentCamera = Workspace.CurrentCamera
  164.         local CameraCFrame = CurrentCamera.CFrame
  165.        
  166.         LocalPlayer.Character = Rig
  167.         CurrentCamera.CameraSubject = RigHumanoid
  168.        
  169.         Wait(RunService.PreRender)
  170.         Workspace.CurrentCamera.CFrame = CameraCFrame
  171.     end)
  172.    
  173.     tableinsert(Connections, Connect(RunService.PostSimulation, function()
  174.         local currentTime = osclock()
  175.        
  176.         for Motor6D, Table in next, Motor6Ds do
  177.             local Part0 = Table.Part0
  178.             local Part1 = Table.Part1
  179.            
  180.             if LimbMotors[Motor6D] then
  181.                 -- Handle limb motors with circular movement
  182.                 local angleOffset = 0
  183.                 local limbName = Part1.Name
  184.                
  185.                 if limbName == "Left Arm" then angleOffset = 0
  186.                 elseif limbName == "Right Arm" then angleOffset = 90
  187.                 elseif limbName == "Left Leg" then angleOffset = 180
  188.                 elseif limbName == "Right Leg" then angleOffset = 270
  189.                 end
  190.                
  191.                 local angle = mathrad(angleOffset + currentTime * CircleSpeed * 50)
  192.                 local x = mathcos(angle) * CircleRadius
  193.                 local z = mathsin(angle) * CircleRadius
  194.                 local y = mathsin(currentTime * 3 + angleOffset * 0.1) * LimbFloatHeight
  195.                
  196.                 -- Get corresponding character limb
  197.                 local charLimb = FindFirstChild(Character, limbName)
  198.                 if charLimb then
  199.                     -- Calculate desired position relative to torso
  200.                     local offset = Vector3new(x, y, z)
  201.                     local desiredCFrame = CFramenew(RigRootPart.Position + offset) * CFrameAngles(
  202.                         mathsin(currentTime * 2 + angleOffset * 0.05) * 0.5,
  203.                         angle,
  204.                         mathcos(currentTime * 1.5 + angleOffset * 0.05) * 0.3
  205.                     )
  206.                    
  207.                     -- Update character limb to match
  208.                     charLimb.CFrame = desiredCFrame
  209.                    
  210.                     -- Calculate motor6D properties
  211.                     Motor6D.DesiredAngle = select(3, ToEulerAnglesXYZ(desiredCFrame, Part0.CFrame))
  212.                    
  213.                     local Delta = Inverse(Motor6D.C0) * (Inverse(Part0.CFrame) * desiredCFrame) * Motor6D.C1
  214.                     local Axis, Angle = ToAxisAngle(Delta)
  215.                    
  216.                     sethiddenproperty(Motor6D, "ReplicateCurrentAngle6D", Axis * Angle)
  217.                     sethiddenproperty(Motor6D, "ReplicateCurrentOffset6D", Delta.Position)
  218.                 end
  219.             else
  220.                 -- Normal motor6D handling for non-limb parts
  221.                 local Part1CFrame = Table.Part1.CFrame
  222.                
  223.                 Motor6D.DesiredAngle = select(3, ToEulerAnglesXYZ(Part1CFrame, Part0.CFrame))
  224.                
  225.                 local Delta = Inverse(Motor6D.C0) * (Inverse(Part0.CFrame) * Part1CFrame) * Motor6D.C1
  226.                 local Axis, Angle = ToAxisAngle(Delta)
  227.                
  228.                 sethiddenproperty(Motor6D, "ReplicateCurrentAngle6D", Axis * Angle)
  229.                 sethiddenproperty(Motor6D, "ReplicateCurrentOffset6D", Delta.Position)
  230.             end
  231.         end
  232.        
  233.         RootPart.AssemblyAngularVelocity = Vector3zero
  234.         RootPart.AssemblyLinearVelocity = Vector3zero
  235.         RootPart.CFrame = RigRootPart.CFrame + Vector3new(0, mathsin(currentTime * 15) * 0.004, 0)
  236.     end))
  237.    
  238.     tableinsert(Connections, Connect(RunService.PreSimulation, function()
  239.         for Index, BasePart in next, GetDescendants(Rig) do
  240.             if IsA(BasePart, "BasePart") then
  241.                 BasePart.CanCollide = false
  242.             end
  243.         end
  244.        
  245.         if DisableCharacterCollisions and not ParentCharacterToRig then
  246.             for Index, BasePart in next, GetDescendants(Character) do
  247.                 if IsA(BasePart, "BasePart") then
  248.                     BasePart.CanCollide = false
  249.                 end
  250.             end
  251.         end
  252.     end))
  253. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement