Advertisement
DrawingJhon

Dummy joints

Jul 17th, 2020 (edited)
406
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.78 KB | None | 0 0
  1. NLS([[local remote = script.Parent:WaitForChild("HumanoidRemote")
  2. remote.OnClientEvent:Connect(function(hum)
  3.     workspace.CurrentCamera.CameraSubject = hum
  4. end)]], script)
  5.  
  6. local dum
  7. do
  8.     local rootPart = owner.Character:findFirstChild("HumanoidRootPart")
  9.     local dist = math.huge
  10.     for i, v in pairs(workspace:GetChildren()) do
  11.         if v:IsA("Model") and v.Name == "Default Dummy" and v ~= owner.Character then
  12.             local torso = v:findFirstChild("Torso")
  13.             if torso and torso:findFirstChild("Weld") then
  14.                 local magn = (rootPart.Position - torso.Position).magnitude
  15.                 if magn < dist then
  16.                     dist = magn
  17.                     dum = v
  18.                 end
  19.             end
  20.         end
  21.     end
  22. end
  23. assert(dum, "No dummy found or dummy is died :(")
  24. local animate = owner.Character:findFirstChild("Animate")
  25. animate.Parent = nil
  26. local lastCF = dum.Torso.CFrame
  27. if dum:findFirstChild("Animate") then
  28.     dum.Animate:Destroy()
  29. end
  30. dum:findFirstChildOfClass("Humanoid"):Destroy()
  31. local h = Instance.new("Part", dum)
  32. h.Size = Vector3.new(2, 2, 1)
  33. h.Transparency = 1
  34. h.Parent = dum
  35. h.CanCollide = false
  36. h.Name = "HumanoidRootPart"
  37. local hum = Instance.new("Humanoid", dum)
  38. local animator = owner.Character:findFirstChildOfClass("Humanoid"):findFirstChild("Animator"):Clone()
  39. animator.Parent = hum
  40. dum.Torso.Weld:Destroy()
  41.  
  42. local f = Instance.new("Motor6D", h)
  43. f.Name = "RootJoint"
  44. f.C0 = CFrame.new(0, 0, 0, -1, 0, 0, 0, 0, 1, 0, 1, -0)
  45. f.C1 = CFrame.new(0, 0, 0, -1, 0, 0, 0, 0, 1, 0, 1, -0)
  46. f.MaxVelocity = 0.1
  47. f.Part0 = h
  48. f.Part1 = dum.Torso
  49.  
  50. local function createMotor6D(name, partOfDum)
  51.     dum.Torso[name]:Destroy()
  52.     local RS = Instance.new("Motor6D", dum.Torso)
  53.     RS.Name = name
  54.     RS.C0 = owner.Character.Torso[name].C0
  55.     RS.C1 = owner.Character.Torso[name].C1
  56.     RS.Part0 = dum.Torso
  57.     RS.Part1 = dum[partOfDum]
  58.     RS.MaxVelocity = 0.1
  59. end
  60. createMotor6D("Right Shoulder", "Right Arm")
  61. createMotor6D("Left Shoulder", "Left Arm")
  62. createMotor6D("Right Hip", "Right Leg")
  63. createMotor6D("Left Hip", "Left Leg")
  64. createMotor6D("Neck", "Head")
  65. local torso = dum:findFirstChild("Torso")
  66.  
  67. local b = Instance.new("Attachment", h)
  68. b.Name = "RootAttachment"
  69. b.CFrame = CFrame.new(0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1)
  70. b.Axis = Vector3.new(1, 0, 0)
  71. b.SecondaryAxis = Vector3.new(0, 1, 0)
  72.  
  73. local BodyColors = Instance.new("BodyColors")
  74. for i, v in pairs(dum:GetChildren()) do
  75.     if v:IsA("BasePart") and v.Name ~= "HumanoidRootPart" then
  76.         pcall(function()
  77.             BodyColors[table.concat(v.Name:split(' ')).."Color"] = v.BrickColor
  78.         end)
  79.     end
  80. end
  81. BodyColors.Parent = dum
  82. wait()
  83. owner.Character = dum
  84. dum.Humanoid.PlatformStand = false
  85. dum.HumanoidRootPart.CFrame = lastCF
  86. script.Parent = owner.Character
  87. local remote = Instance.new("RemoteEvent", script)
  88. remote.Name = "HumanoidRemote"
  89. remote:FireClient(owner, hum)
  90. animate:Clone().Parent = dum
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement